I guess this was more of a feature request, since I will soon have to tackle an 
application using PostgreSQL that forces case-sensitive naming.

On Feb 25, 2011, at 3:03 PM, DenesL wrote:

> 
> What issue?.
> 
> 
> On Feb 25, 11:32 am, Ross Peoples <[email protected]> wrote:
>> True, but I'd still have the issue of:
>> 
>> db().select(global_settings.SettingName)
>> 
>> when using any field names.
>> 
>> On Feb 25, 2011, at 11:27 AM, DenesL wrote:
>> 
>> 
>> 
>>> Instead of using db.GlobalSettings you can assign it to a variable
>> 
>>> global_settings = db.GlobalSettings
>> 
>>> and use the var in place for all practical purposes e.g.
>> 
>>> db().select(db.GlobalSettings.ALL)
>> 
>>> becomes
>> 
>>> db().select(global_settings.ALL)
>> 
>>> On Feb 25, 11:04 am, Ross Peoples <[email protected]> wrote:
>>>> I am integrating with a legacy database running MSSQL. The table names are
>>>> in camel case, so the global settings table is called GlobalSettings. Here
>>>> is the table definition as I have it:
>> 
>>>> db.define_table('GlobalSettings',
>>>>     Field('SettingName', length=255),
>>>>     Field('SettingValue', length=255),
>>>>     Field('Setting_PKey', 'id'),
>>>>     migrate=False
>>>> )
>> 
>>>> Doing a select on this table would look like this:
>>>> db().select(db.GlobalSettings.ALL)
>> 
>>>> I plan to eventually rename the tables and fields once my web2py 
>>>> application
>>>> takes over the current C# version of the project. My question is, would it
>>>> be possible to add an argument to define_table() and Field() that would
>>>> allow you to give a different name to the tables and fields for use in 
>>>> later
>>>> code? Maybe like an alias= attribute or something?
>> 
>>>> With something like that, I could apply the alias argument to each table 
>>>> and
>>>> field definition, then when I'm ready to rename the tables and fields in 
>>>> the
>>>> database, all I have to do is change the names in the db.py file. 
>>>> Otherwise,
>>>> I would have to change every line that uses the db object. Using an alias
>>>> argument would allow me to call and refer to the table or field by whatever
>>>> name I want. So my table definition would look like this:
>> 
>>>> db.define_table('GlobalSettings',
>>>>     Field('SettingName', length=255, alias='name'),
>>>>     Field('SettingValue', length=255, alias='value'),
>>>>     Field('Setting_PKey', 'id', alias='id'),
>>>>     migrate=False,
>>>>     alias='global_settings'
>>>> )
>> 
>>>> Then a select would look like this:
>>>> db().select(db.global_settings.ALL)
>> 
>>>> And when I change the name of the table and fields in the database, my 
>>>> table
>>>> definition would be changed to look like this:
>> 
>>>> db.define_table('global_settings',
>>>>     Field('name', length=255),
>>>>     Field('value', length=255)
>>>> )
>> 
>>>> No changes to any other code would be necessary, as I would already be 
>>>> using
>>>> db.global_settings.name to refer to the GlobalSettings.SettingName field.
>>>> You will notice that in the last table definition above, I have removed
>>>> migrate=False, as the table can now be controlled using web2py's built in
>>>> migration functions.
>> 
>>>> I don't know how difficult a task it would be to add this functionality, 
>>>> but
>>>> it could go a long way into allowing web2py to integrate with legacy
>>>> databases, and optionally take over completely from the legacy application
>>>> using the legacy database.
>> 
>> 
>> 
>>  smime.p7s
>> 5KViewDownload

Reply via email to