On Fri, 2009-07-17 at 07:42 +0530, Anand Chitipothu wrote:
> > I've experimented a bit with web.db sources and managed to hack in a few
> > lines of code that cause web.db methods to double-quote table and column
> > names.
>
> Are you sure that works for database engine? IIRC, MySQL uses
> backquote for escaping column names. May be we this should be an
> optional feature, selected by some config value. something like this:
You're right. It fails in MySQL. I've used SQLite and Postgres, so I
assumed it was standard.
> >>> db = web.database(dbn='sqlite', db='a.db')
> >>> db.insert('test', name='testing', _test=True)
> <sql: "INSERT INTO test (name) VALUES ('testing')">
>
> >>> db.quote_column_names = True
> >>> db.insert('test', name='testing', _test=True)
> <sql: "INSERT INTO \"test\" (\"name\") VALUES ('testing')">
>
> I think the quote function should go as a method in DB class so that
> other databases can use a different quote character. Can you also add
> a testcase in tests/db.py?
I think there could be two properties:
``column_quote_char`` that is set by the backend class (defaulting to
'', empty string)
and
``column_quote`` which is a boolean defaulting to False (or whatever you
think should be the default.
I'll work on this some more, add tests, and post here again. Thanks for
the tips.
Best regards,
--
Branko
eml: [email protected]
alt: [email protected]
blg1: http://sudologic.blogspot.com/
blg2: http://brankovukelic.blogspot.com/
img: http://picasaweb.google.com/bg.branko
twt: http://www.twitter.com/foxbunny/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web.py" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/webpy?hl=en
-~----------~----~----~----~------~----~------~--~---