Yep, my intention was to use field_list afterwards, and it's simple enough 
to get around the problem. The bigger issue may be that the side effect in 
question can cause bugs that are a bit trickier than usual to track down, 
since it's happening under the hood, so to speak, and is unexpected. I 
thought it might be a good idea to have SQLFORM do the copying; I suppose 
the downside is that this would entail a slight performance hit, but the 
upside is that it averts an unanticipated behavior from SQLFORM. If the 
development team and other users aren't too bothered by it, perhaps it's 
better to leave it as is, but I thought it was worth a mention that this 
could be an issue.



On Wednesday, February 11, 2015 at 12:33:16 PM UTC-5, Anthony wrote:
>
> If you need to use field_list elsewhere and don't want it to be mutated by 
> SQLFORM, then just pass a copy of it to SQLFORM instead.
>
> import copy
> form = SQLFORM(db.t_table_1, fields = copy.copy(field_list))
>
> I suppose SQLFORM could be changed to do the copying itself.
>
> Anthony
>
> On Wednesday, February 11, 2015 at 12:10:53 PM UTC-5, Spokes wrote:
>>
>> After passing a list to SQLFORM's 'fields' parameter, it appears that 
>> 'id' is prepended to that list. For example:
>>
>> field_list = ['field_1', 'field_2', 'field_3', ...]
>> form = SQLFORM(db.t_table_1, fields = field_list)
>>
>> After the above statements are executed, 'field_list' is equal to ['id', 
>> 'field_1', 'field_2', 'field_3', ...]. Has anyone else noticed the same 
>> issue? If this is a common occurrence, rather than something idiosyncratic 
>> to my program (and I haven't found anything in my code that's likely to 
>> cause this to happen), it doesn't seem like a desirable behavior from 
>> SQLFORM.
>>
>

-- 
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