Thanks Doug, I was understanding that, it much clearer now though. Your use case for rname seems exactly what rname is for.
Good luck Richard On Wed, May 31, 2017 at 6:15 PM, Doug Taylor <[email protected]> wrote: > Hi Richard - > > Thanks for response. I am running web2py version: > Version 2.14.6-stable+timestamp.2016.05.10.00.21.47 > > I'm using rname because postgresql doesn't like case sensitive table and > field names much, and neither do my colleagues, but I like CamelCase in my > code, so as you say, for code readability. Reproducing the problem is very > easy. All I did was comment out the 'OS' (rname 'file_server_os') field > from my model as below and set migrate to True. The define table statement > failed immediately because the SQL was using the Table and Field names, > rather than the rnames (lower_case_with_underscores) in the ALTER TABLE > statement. > > db.define_table('FileServer', > Field('HostName', rname='host_name', type='string', length=32, > label='Host', comment='The Host Name of the Server on the network'), > Field('Address', rname='file_server_address', type='string', > length=32, label='Address', comment='The Address of the Server'), > Field('CommissioningDate', rname='file_server_comm_date', > type='date', label='Commissioning Date', comment='The date on which the > Server was commissioned (YYYY-MM-DD)'), > #Field('OS', rname='file_server_os', type='string', > length=32, label='OS', comment='The Operating System running on the > Server'), > audit, > rname='file_server', > format='%(HostName)s', > singular='Server', > plural='Servers', > migrate=True) > > I will post to the pydal repo as Anthony suggests. > > On Wednesday, May 31, 2017 at 7:03:38 PM UTC+2, Richard wrote: >> >> Hi Doug, >> >> I am not sure I follow and understand the exact problem, it maybe me, but >> can you provide model before and after and. >> >> You may also try to reproduce the bug and explain the exact step to >> trigger it and pack an dummy app to facilitate the reproducing of the bug >> for us. >> >> Also, specify the version of web2py, trunk or latest official release?? >> >> Notice that rname is relatively recent feature, and I am not sure that it >> is wildly use, so it may suffer from some flaw. To my knowledge it mostly >> intent to be used with legacy database schema that can be alter so you can >> specify different field/table name in the database and the model to improve >> code readability for instance or other specific purposes that would require >> having a different set of field name in the database and in the front >> end... I hardly see the purpose to use it in a new projet as you already >> have field name and label to set proper end-user field name and database >> compliant field name. >> >> Thanks >> >> Richard >> >> >> >> On Wed, May 31, 2017 at 10:58 AM, Doug Taylor <[email protected]> >> wrote: >> >>> Hi I'm a relative noob to web2py and python - but plenty of dev >>> experience. Must say it has been a smooth learning curve for me and most >>> stuff just works out the box... thanks Massimo! >>> >>> Pretty sure I found a bug here though. Running on ubuntu Xenial, >>> postgresql 9.6 with psycopg2. I have a table defined thus: >>> >>> db.define_table('FileServer', >>> Field('HostName', rname='host_name', type='string', >>> length=32, label='Host', comment='The Host Name of the Server on the >>> network'), >>> Field('Address', rname='file_server_address', type='string', >>> length=32, label='Address', comment='The Address of the Server'), >>> Field('CommissioningDate', rname='file_server_comm_date', >>> type='date', label='Commissioning Date', comment='The date on which the >>> Server was commissioned (YYYY-MM-DD)'), >>> Field('OS', rname='file_server_os', type='string', >>> length=32, label='OS', comment='The Operating System running on the >>> Server'), >>> audit, >>> rname='file_server', >>> format='%(HostName)s', >>> singular='Server', >>> plural='Servers', >>> migrate=True) >>> >>> Decided to drop the OS column and create a new relation for it instead. >>> The migration fails with "relation fileserver does not exist". Went to look >>> in my sql.log file and found these entries: >>> >>> from run previous when table is created >>> >>> timestamp: 2017-05-30T13:10:09.134114 >>> CREATE TABLE file_server( >>> id SERIAL PRIMARY KEY, >>> host_name VARCHAR(32), >>> file_server_address VARCHAR(32), >>> file_server_comm_date DATE, >>> file_server_os VARCHAR(32), >>> created_on TIMESTAMP, >>> created_by INTEGER REFERENCES auth_user (id) ON DELETE CASCADE , >>> updated_on TIMESTAMP, >>> updated_by INTEGER REFERENCES auth_user (id) ON DELETE CASCADE , >>> is_validated CHAR(1), >>> is_active CHAR(1) >>> ); >>> success! >>> >>> >>> when I kick off the migration >>> >>> timestamp: 2017-05-31T15:43:53.289791 >>> ALTER TABLE FileServer DROP COLUMN os; >>> >>> notice that rname is specified in define_table (highlighted above) >>> >>> Seems the migration code observes rname for table creation (table and >>> column name) but not dropping the column where ALTER TABLE uses the Table >>> and Field names in the SQL?? I find it hard to believe that such a mature >>> product could suffer such a basic bug. Not sure this is the place to report >>> it. Somebody direct me to the right forum? >>> >>> Having a whale of a time otherwise \m/ >>> >>> -- >>> 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 [email protected]. >>> 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 [email protected]. > 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 [email protected]. For more options, visit https://groups.google.com/d/optout.

