[Gambas-user] Forbid DataSource to fetch certain fields
Tobias Boege
taboege at ...626...
Sun Sep 30 20:09:00 CEST 2012
On Sun, 30 Sep 2012, Beno?t Minisini wrote:
> Le 30/09/2012 11:48, Tobias Boege a ?crit :
> >>>> DataSource can take a SQL request instead of a table. But then you
> >>>> cannot modify the records.
> >>>>
> >>>> --
> >>>> Beno?t Minisini
> >>>
> >>> Bruce, clever idea. That's certainly feasible but a workaround.
> >>> Benoit, is there any reason there is no such DataSource.Columns As String[]?
> >>>
> >>> Regards,
> >>> Tobi
> >>>
> >>
> >> Because using your own SQL request is more powerful.
> >>
> >> --
> >> Beno?t Minisini
> >>
> >
> > Could you please elaborate on that? I don't understand how to do it. Do you
> > mean I could use:
> >
> > DataSource.Table = "SELECT id,title FROM my_table" ' instead of "my_table"
>
> Yes.
>
> >
> > If you say that one couldn't modify records when using their own SQL it may
> > be more powerful in that one case but limiting in the other... Do I get that
> > right?
> >
> > Regards,
> > Tobi
> >
>
> To modify a record, I need its primary key. But when doing a SELECT, I
> cannot know for sure how to get it.
>
> But maybe I can detect that the SELECT request is on just one table, and
> add the primary key to it.
>
> Or add a way to specify which fields we want from the table. But I have
> to add a property for that everywhere we find a Table property ; or find
> another way...
Sorry, I missed my initial goal :-/ It was to *display* only certain fields
and the ".Table = sSql" trick does it.
I just wondered why I had to bother using my own SQL. So the following is
just for interest. I've got the impression that I don't know enough about
the infrastructure but naively I'd say we could turn (from DataTable.class):
hReq = Request.Select($aKey).From($sTable).Where($sFilter).OrderBy($aKey)
into
hReq = Request.Select($aKey.Copy().Insert($aCols)).From($sTable)....
where $aCols corresponds to a DataSource.Columns As String[] property, and
everything is clean.
I understand if this is considered to be comfort overkill or even wrong but
it would then be analoguous to DataView.Columns but at a deeper level. It
logical and easy to understand how they are related and what the differences
are...?
Anyway, thanks.
Regards,
Tobi
More information about the User
mailing list