[Gambas-devel] Database field name error.

ron ronstk at ...124...
Thu Apr 27 08:48:59 CEST 2006


On Wednesday 26 April 2006 23:01, Benoit Minisini wrote:
> > I suggest to do it in the mysql driver to.
> > Adding backticks does not harm but without them it does/can
> > create errors for unexperiented people they do not understand.
> >
> >
> > my 3 cents
> >
> > Ron
> >
> >
> 
> You are right, I should quoting field names everywhere.
> 
> Regards,
> 
Thank you master of universe :)

But a little warning.
If the user uses COUNT(fielddname) it is fieldname that should be quoted.
COUNT can be also SUM(), AVG(), MAX(), MIN(), CAT(filed1,field2) or even 
more complex formulas. I use for that SQL syntax always upercase with mysql.
It could be easy for the quoting to require from the user to do it
that way so only mixed or lowcase are the db,table or field names for quoting.

SELECT MAX(`tbl1`.`field1`), `tblname2`.`field3` FROM `table1`, `table2`

For mysql the qouting for database objects is backtick and for arguments
it is single or double quote, this for the other readers. 

Consider for the Request class to use for .From(tbl as string)
the same method as current used for fields.
It is valid, at least for mysql, to use *FROM `table1`. `table2`* wich result 
in a join between the tables and done here by mysql.

Ron




More information about the Devel mailing list