Try using rname and/or quoting

http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#rname--Record-representation

http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Database-quoting-and-case-settings--entity_quoting--ignore_field-

2016-07-11 17:05 GMT+02:00 David Orme <david.o...@gmail.com>:

> Hello,
>
> I've got an application with a PostgreSQL backend that shares a small
> subset of tables with another application. At the moment, I have Web2Py
> defining all the tables and the expectation is that the other application
> just read information from the tables (and does what it likes with any
> other non Web2Py tables).
>
> However, the other application has some fairly hard wired expectations of
> capitalised names for tables and fields. That isn't great for all sorts of
> reasons (like having to quote all the field and table names in any SQL
> queries):
>
>
> https://www.postgresql.org/docs/current/static/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS
>
> What I'm trying to figure out is if there is a sensible workaround to
> accommodate this in the Web2Py app? Obviously, if I define the table
> through the DAL, then it converts everything to lower_case as the Postgres
> standard. That is, these two create the same table:
>
> db.define_table("Project",
>                 Field("Oid", length=64, default=uuid.uuid4),
>                 Field("contents","text"))
>
> db.define_table("project",
>                 Field("oid", length=64, default=uuid.uuid4),
>                 Field("contents","text"))
>
> From the DB backend, I can create tables that have the required
> capitalisation, but one *must have* quoted identifiers.
>
> -- desired table
> create table "Project" (id SERIAL,
>                         "Oid" uuid,
>                         contents text);
> -- actually created table
> create table Project (id SERIAL,
>                       Oid uuid,
>                       contents text);
>
> Having tried some things I think I can answer my own question, I've found
> that the rname argument does seem to allow this to work! So the following
> Web2Py code, creates the 'desired table' as desribed in the SQL code above:
>
> db.define_table('project',
>                 Field('oid', length=64, default=uuid.uuid4, rname='"Oid"'
> ),
>                 Field('contents','text'),
>                 rname='"Project"')
>
> I'm going to post this anyway in case anyone else runs into the issue -
> and in case there is a serious problem with this solution!
>
> Cheers,
> David
>
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to