[web2py] Re: alias field names

2011-05-24 Thread Massimo Di Pierro
How about my_descriptive_field_name = db.a On May 24, 9:06 am, Plumo wrote: > the database I use (GAE) has a big overhead for long field names. > So I want to change Field('my_descriptive_field_name') to Field('a') and use > an alias to keep accessing with 'my_descriptive_field_name'. > Can this

[web2py] Re: alias field names

2015-10-03 Thread Nguyen Minh Tuan
Hi all, My situation is that I have to work with already defined tables. There is a field name 'pass', this is keyword of Python, I don't how to solve this. So I think alias for table field is necessary. Anyone can suggest for this situation? Thanks in advance! Regards, Tuan. -- Resources: -

[web2py] Re: alias field names

2015-10-03 Thread 黄祥
perhaps you can use dal alias ref: http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Self-Reference-and-aliases best regards, stifan On Saturday, October 3, 2015 at 3:03:45 PM UTC+7, Nguyen Minh Tuan wrote: > > Hi all, > > My situation is that I have to work with alread

Re: [web2py] Re: alias field names

2011-05-24 Thread Richard Baron Penman
would this work? db.table_name.my_descriptive_field_name = db.table_name.a I would rather avoid extra global variables and changing my database queries. On Wed, May 25, 2011 at 12:21 AM, Massimo Di Pierro < massimo.dipie...@gmail.com> wrote: > How about > > my_descriptive_field_name = db.a > >

Re: [web2py] Re: alias field names

2011-05-24 Thread Vinicius Assef
I think he is talking about this, if it would be SQL: SELECT my_descriptive_name as a FROM my_table In web2py, something near: Field('my_descriptive_field_name', 'string', alias='a') And, in code: print db.my_table.a -- Vinicius Assef. On Tue, May 24, 2011 at 11:21 AM, Massimo Di Pierro wrot

Re: [web2py] Re: alias field names

2011-05-24 Thread Richard Baron Penman
For space reasons I want the database to internally store 'a', but be able to use the longer name in code for readability. So I think your example should instead be: Field('a', 'string', alias='my_descriptive_field_name') But does that alias parameter exist? Not according to docs: http://web2py.c

Re: [web2py] Re: alias field names

2011-05-24 Thread Vinicius Assef
Richard, I didn't understand your "space reasons", but alias param does not exist today. Massimo can tell us if it will be implemented. IMHO it is a good idea, mainly for legacy tables, with legacy names. -- Vinicius Assef. On Tue, May 24, 2011 at 12:36 PM, Richard Baron Penman wrote: > For s

Re: [web2py] Re: alias field names

2011-05-24 Thread pbreit
Massimo's example gets you roughly the same result. Having a constant or an alias is pretty much the same.

Re: [web2py] Re: alias field names

2011-05-24 Thread Vinicius Assef
Right, pbreit. But if it could be addressed by the DAL, it would demand less programmer's effort and DRY would be an ally. I vote for an "alias" param in Field(). Who is in? Just a suggestion. -- Vinicius Assef. On Tue, May 24, 2011 at 1:13 PM, pbreit wrote: > Massimo's example gets you roug

Re: [web2py] Re: alias field names

2011-05-24 Thread Richard Baron Penman
On Wed, May 25, 2011 at 1:50 AM, Vinicius Assef wrote: > > I didn't understand your "space reasons" > see first post

Re: [web2py] Re: alias field names

2011-05-24 Thread Richard Baron Penman
On Wed, May 25, 2011 at 2:13 AM, pbreit wrote: > Massimo's example gets you roughly the same result. so are you saying this would work too? db.table_name.my_descriptive_field_name = db.table_name.a Having a constant or an alias is pretty much the same. main drawback is additional global v

Re: [web2py] Re: alias field names

2011-05-24 Thread pbreit
An alias would be global too? I don't think this would work: db.table_name.my_descriptive_field_name = db.table_name.a But these would: db_table_name_my_descriptive_field_name = db.table_name.a db_table_name = Storage() db_table_name.my_descriptive_field_name = db.table_name.a

Re: [web2py] Re: alias field names

2011-05-24 Thread Anthony
On Tuesday, May 24, 2011 11:57:00 PM UTC-4, pbreit wrote: > > An alias would be global too? > > I don't think this would work: > db.table_name.my_descriptive_field_name = db.table_name.a > As far as I can tell, the above does appear to work, at least for some purposes. Anthony

Re: [web2py] Re: alias field names

2011-05-25 Thread howesc
i don't see the reason for this. true, from GAE's docs (http://code.google.com/appengine/articles/storage_breakdown.html): "Because App Engine's datastore is essentially schemaless, every entity of a particular kind must store the name of each property in addition to the value, even if every o

Re: [web2py] Re: alias field names

2011-05-25 Thread Richard Baron Penman
Currently the datastore is at 1.3GB and costs next to nothing, so normally I wouldn't care. But this project is for a client who doesn't want to enable billing so I am trying every optimization I can find. On Thu, May 26, 2011 at 7:16 AM, howesc wrote: > i don't see the reason for this. true,