That makes sense.
Thank you.
On Thursday, March 7, 2013 2:50:29 PM UTC-5, Niphlod wrote:
>
> seems that whatever dict you pass only the values pertaining to the table
> gets filled.
> It's useful, e.g. for fields coming from multiple tables that needs to be
> inserted , e.g. in a SQLFORM holding 2 tables.
> >>> db.define_table('testshortcuts', Field('abcd'), Field('efgh'))
> <Table testshortcuts (id,abcd,efgh)>
> >>> db.testshortcuts[0] = dict(a=1)
> >>> for row in db(db.testshortcuts).select():
> ... print row
> ...
> <Row {'abcd': None, 'id': 1, 'efgh': None}>
> >>> db._lastsql
> 'SELECT testshortcuts.id, testshortcuts.abcd, testshortcuts.efgh FROM
> testshortcuts WHERE (testshortcuts.id IS NOT NULL);'
> >>> db.testshortcuts[0] = dict(a=1)
> >>> db._lastsql
> 'INSERT INTO testshortcuts(abcd,efgh) VALUES (NULL,NULL);'
> >>>
>
> I don't know what agenda had the author or this feature, but it seems to
> have a point for flexibility.
>
> On Thursday, March 7, 2013 8:00:08 PM UTC+1, Cliff Kachinske wrote:
>>
>> Niphlod:
>> It's one of the dal shortcuts. Similar to db.mytable[0] =
>> dict(myfield='somevalue')
>>
>>
>> The first one should raise an exception, but instead it inserts a record and
>> ignores the misnamed field.
>>
>>
>> Richard: The thing doesn't even fail. It just ignores the incorrect field
>> name and inserts a record. Checking with psql I find that it inserted
>> values for the properly named fields.
>>
>>
>> I tried to see what was going on with db._lastsql, but I got back the sql
>> that fetched the id of the last insert.
>>
>>
>> Time permitting I'll look at the dal code to see if I can figure out what's
>> going on.
>>
>>
>> On Thursday, March 7, 2013 11:03:47 AM UTC-5, Niphlod wrote:
>>>
>>> I quite don't get the issue: what are you trying to do with those dicts ?
>>>
>>> On Thursday, March 7, 2013 4:54:25 PM UTC+1, Cliff Kachinske wrote:
>>>>
>>>> I don't know why this code does not fail. It seems like it should
>>>> because there is no file 'sale_product_id' in the table.
>>>>
>>>> lots = db.customer_order_product_lots
>>>> lots[0] = dict(
>>>>
>>>> customer_order_product_id=customer_order_product_id,
>>>> sale_product_id=request.args(0),
>>>> quantity_allocated=v,
>>>> requested_ship_date=form.vars[req_date],
>>>> ship_date=form.vars[act_date],
>>>> )
>>>>
>>>> The code should look like this:
>>>> lots = db.customer_order_product_lots
>>>> lots[0] = dict(
>>>>
>>>> customer_order_product_id=customer_order_product_id,
>>>> production_job_id=production_job_id,
>>>> quantity_allocated=v,
>>>> requested_ship_date=form.vars[req_date],
>>>> ship_date=form.vars[act_date],
>>>> )
>>>>
>>>> Can anyone tell me what's going on?
>>>> Thanks,
>>>> Cliff Kachinske
>>>>
>>>
--
---
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/groups/opt_out.