[web2py] Re: Is this a bug? DAL update records using an expression

2013-03-14 Thread LightDot
This probably breaks quite a few apps out there? It did one for us.

Did anyone open a bug report?

Regards,
Ales

On Wednesday, March 13, 2013 1:22:57 AM UTC+1, Alex wrote:

 I've got the same problem. I have a field with type decimal(12,4), I can 
 add a number to this field but not subtract. So instead of
 db(db.client_service.id == id).update(minutes_done = 
 db.client_service.minutes_done 
 - minutes)

 I have to write
 minutes = -minutes
 db(db.client_service.id == id).update(minutes_done = 
 db.client_service.minutes_done 
 + minutes)

 as a workaround. that makes the code much harder to read. I see no reason 
 why the first query should not be possible. Any chance this will be fixed?

 Alex

 Am Mittwoch, 6. März 2013 19:30:22 UTC+1 schrieb Cliff Kachinske:

 I see what the code is doing.

 Would this work?

 if db._adapter.driver.__name__ in ('sqlite'): # maybe others?
 if self.type in ('integer','bigint'):
 result_type = 'integer'
 elif self.type in ['date','time','datetime','double','float']:
 result_type = 'double'
 else:
 raise SyntaxError(subtraction operation not supported 
 for type)
 else:
 result_type = self.type



 On Wednesday, March 6, 2013 11:55:20 AM UTC-5, Massimo Di Pierro wrote:

 According to the code:

 if self.type in ('integer','bigint'):
 result_type = 'integer'
 elif self.type in ['date','time','datetime','double','float']:
 result_type = 'double'
 else:
 raise SyntaxError(subtraction operation not supported for 
 type)

 what is the type of db.production_jobs.quantity_on_hand?

 On Wednesday, 6 March 2013 08:45:20 UTC-6, Cliff Kachinske wrote:

 V 2.4.2

 Apparently I can add a negative number in an update expression but I 
 cannot subtract a positive number.  


 Snippet:

 delta = new_allocation - record.quantity_allocated 
 db(db.production_jobs.id==record.production_job_id).update(
 quantity_on_hand=db.production_jobs.quantity_on_hand - delta # 
 subtraction.  DAL will not like it
 )

 Snippet raises this exception:

 File 
 /home/cjk/pybin/w-2-4-2/web2py/applications/Inventory/controllers/customer_order_product_lots.py,
  line 70, in update_lot_record
  quantity_on_hand=db.production_jobs.quantity_on_hand - delta
  File /home/cjk/pybin/w-2-4-2/web2py/gluon/dal.py, line 8820, in __sub__
  raise SyntaxError(subtraction operation not supported for type)
 SyntaxError: subtraction operation not supported for type

 Hackish workaround:

 delta = -(new_allocation - record.quantity_allocated) # flip value to 
 negative
 db(db.production_jobs.id==record.production_job_id).update(
 quantity_on_hand=db.production_jobs.quantity_on_hand + delta # add 
 negative number.  DAL okay with this
 )


 Is this the expected behavior?

 Or am I missing something?




-- 

--- 
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/groups/opt_out.




[web2py] Re: Is this a bug? DAL update records using an expression

2013-03-14 Thread Alex
I just opened a bug report (Issue 1391).

Alex

Am Donnerstag, 14. März 2013 13:56:34 UTC+1 schrieb LightDot:

 This probably breaks quite a few apps out there? It did one for us.

 Did anyone open a bug report?

 Regards,
 Ales

 On Wednesday, March 13, 2013 1:22:57 AM UTC+1, Alex wrote:

 I've got the same problem. I have a field with type decimal(12,4), I can 
 add a number to this field but not subtract. So instead of
 db(db.client_service.id == id).update(minutes_done = 
 db.client_service.minutes_done 
 - minutes)

 I have to write
 minutes = -minutes
 db(db.client_service.id == id).update(minutes_done = 
 db.client_service.minutes_done 
 + minutes)

 as a workaround. that makes the code much harder to read. I see no reason 
 why the first query should not be possible. Any chance this will be fixed?

 Alex

 Am Mittwoch, 6. März 2013 19:30:22 UTC+1 schrieb Cliff Kachinske:

 I see what the code is doing.

 Would this work?

 if db._adapter.driver.__name__ in ('sqlite'): # maybe others?
 if self.type in ('integer','bigint'):
 result_type = 'integer'
 elif self.type in ['date','time','datetime','double','float']:
 result_type = 'double'
 else:
 raise SyntaxError(subtraction operation not supported 
 for type)
 else:
 result_type = self.type



 On Wednesday, March 6, 2013 11:55:20 AM UTC-5, Massimo Di Pierro wrote:

 According to the code:

 if self.type in ('integer','bigint'):
 result_type = 'integer'
 elif self.type in ['date','time','datetime','double','float']:
 result_type = 'double'
 else:
 raise SyntaxError(subtraction operation not supported for 
 type)

 what is the type of db.production_jobs.quantity_on_hand?

 On Wednesday, 6 March 2013 08:45:20 UTC-6, Cliff Kachinske wrote:

 V 2.4.2

 Apparently I can add a negative number in an update expression but I 
 cannot subtract a positive number.  


 Snippet:

 delta = new_allocation - record.quantity_allocated 
 db(db.production_jobs.id==record.production_job_id).update(
 quantity_on_hand=db.production_jobs.quantity_on_hand - delta # 
 subtraction.  DAL will not like it
 )

 Snippet raises this exception:

 File 
 /home/cjk/pybin/w-2-4-2/web2py/applications/Inventory/controllers/customer_order_product_lots.py,
  line 70, in update_lot_record
  quantity_on_hand=db.production_jobs.quantity_on_hand - delta
  File /home/cjk/pybin/w-2-4-2/web2py/gluon/dal.py, line 8820, in __sub__
  raise SyntaxError(subtraction operation not supported for type)
 SyntaxError: subtraction operation not supported for type

 Hackish workaround:

 delta = -(new_allocation - record.quantity_allocated) # flip value to 
 negative
 db(db.production_jobs.id==record.production_job_id).update(
 quantity_on_hand=db.production_jobs.quantity_on_hand + delta # 
 add negative number.  DAL okay with this
 )


 Is this the expected behavior?

 Or am I missing something?




-- 

--- 
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/groups/opt_out.




[web2py] Re: Is this a bug? DAL update records using an expression

2013-03-12 Thread Alex
I've got the same problem. I have a field with type decimal(12,4), I can 
add a number to this field but not subtract. So instead of
db(db.client_service.id == id).update(minutes_done = 
db.client_service.minutes_done 
- minutes)

I have to write
minutes = -minutes
db(db.client_service.id == id).update(minutes_done = 
db.client_service.minutes_done 
+ minutes)

as a workaround. that makes the code much harder to read. I see no reason 
why the first query should not be possible. Any chance this will be fixed?

Alex

Am Mittwoch, 6. März 2013 19:30:22 UTC+1 schrieb Cliff Kachinske:

 I see what the code is doing.

 Would this work?

 if db._adapter.driver.__name__ in ('sqlite'): # maybe others?
 if self.type in ('integer','bigint'):
 result_type = 'integer'
 elif self.type in ['date','time','datetime','double','float']:
 result_type = 'double'
 else:
 raise SyntaxError(subtraction operation not supported for 
 type)
 else:
 result_type = self.type



 On Wednesday, March 6, 2013 11:55:20 AM UTC-5, Massimo Di Pierro wrote:

 According to the code:

 if self.type in ('integer','bigint'):
 result_type = 'integer'
 elif self.type in ['date','time','datetime','double','float']:
 result_type = 'double'
 else:
 raise SyntaxError(subtraction operation not supported for 
 type)

 what is the type of db.production_jobs.quantity_on_hand?

 On Wednesday, 6 March 2013 08:45:20 UTC-6, Cliff Kachinske wrote:

 V 2.4.2

 Apparently I can add a negative number in an update expression but I cannot 
 subtract a positive number.  


 Snippet:

 delta = new_allocation - record.quantity_allocated 
 db(db.production_jobs.id==record.production_job_id).update(
 quantity_on_hand=db.production_jobs.quantity_on_hand - delta # 
 subtraction.  DAL will not like it
 )

 Snippet raises this exception:

 File 
 /home/cjk/pybin/w-2-4-2/web2py/applications/Inventory/controllers/customer_order_product_lots.py,
  line 70, in update_lot_record
  quantity_on_hand=db.production_jobs.quantity_on_hand - delta
  File /home/cjk/pybin/w-2-4-2/web2py/gluon/dal.py, line 8820, in __sub__
  raise SyntaxError(subtraction operation not supported for type)
 SyntaxError: subtraction operation not supported for type

 Hackish workaround:

 delta = -(new_allocation - record.quantity_allocated) # flip value to 
 negative
 db(db.production_jobs.id==record.production_job_id).update(
 quantity_on_hand=db.production_jobs.quantity_on_hand + delta # add 
 negative number.  DAL okay with this
 )


 Is this the expected behavior?

 Or am I missing something?




-- 

--- 
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/groups/opt_out.




[web2py] Re: Is this a bug? DAL update records using an expression

2013-03-06 Thread Massimo Di Pierro
According to the code:

if self.type in ('integer','bigint'):
result_type = 'integer'
elif self.type in ['date','time','datetime','double','float']:
result_type = 'double'
else:
raise SyntaxError(subtraction operation not supported for 
type)

what is the type of db.production_jobs.quantity_on_hand?

On Wednesday, 6 March 2013 08:45:20 UTC-6, Cliff Kachinske wrote:

 V 2.4.2

 Apparently I can add a negative number in an update expression but I cannot 
 subtract a positive number.  


 Snippet:

 delta = new_allocation - record.quantity_allocated 
 db(db.production_jobs.id==record.production_job_id).update(
 quantity_on_hand=db.production_jobs.quantity_on_hand - delta # 
 subtraction.  DAL will not like it
 )

 Snippet raises this exception:

 File 
 /home/cjk/pybin/w-2-4-2/web2py/applications/Inventory/controllers/customer_order_product_lots.py,
  line 70, in update_lot_record
  quantity_on_hand=db.production_jobs.quantity_on_hand - delta
  File /home/cjk/pybin/w-2-4-2/web2py/gluon/dal.py, line 8820, in __sub__
  raise SyntaxError(subtraction operation not supported for type)
 SyntaxError: subtraction operation not supported for type

 Hackish workaround:

 delta = -(new_allocation - record.quantity_allocated) # flip value to negative
 db(db.production_jobs.id==record.production_job_id).update(
 quantity_on_hand=db.production_jobs.quantity_on_hand + delta # add 
 negative number.  DAL okay with this
 )


 Is this the expected behavior?

 Or am I missing something?




-- 

--- 
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/groups/opt_out.




[web2py] Re: Is this a bug? DAL update records using an expression

2013-03-06 Thread Cliff Kachinske
Here is the field def:
 
 
  Field('quantity_on_hand', 'decimal(12,3)', default=0.0,
 writable=False, readable= False,
 requires=IS_EMPTY_OR(IS_DECIMAL_IN_RANGE(0, 
.999)),
 ),



On Wednesday, March 6, 2013 9:45:20 AM UTC-5, Cliff Kachinske wrote:

 V 2.4.2

 Apparently I can add a negative number in an update expression but I cannot 
 subtract a positive number.  


 Snippet:

 delta = new_allocation - record.quantity_allocated 
 db(db.production_jobs.id==record.production_job_id).update(
 quantity_on_hand=db.production_jobs.quantity_on_hand - delta # 
 subtraction.  DAL will not like it
 )

 Snippet raises this exception:

 File 
 /home/cjk/pybin/w-2-4-2/web2py/applications/Inventory/controllers/customer_order_product_lots.py,
  line 70, in update_lot_record
  quantity_on_hand=db.production_jobs.quantity_on_hand - delta
  File /home/cjk/pybin/w-2-4-2/web2py/gluon/dal.py, line 8820, in __sub__
  raise SyntaxError(subtraction operation not supported for type)
 SyntaxError: subtraction operation not supported for type

 Hackish workaround:

 delta = -(new_allocation - record.quantity_allocated) # flip value to negative
 db(db.production_jobs.id==record.production_job_id).update(
 quantity_on_hand=db.production_jobs.quantity_on_hand + delta # add 
 negative number.  DAL okay with this
 )


 Is this the expected behavior?

 Or am I missing something?




-- 

--- 
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/groups/opt_out.




[web2py] Re: Is this a bug? DAL update records using an expression

2013-03-06 Thread Cliff Kachinske
I see what the code is doing.

Would this work?

if db._adapter.driver.__name__ in ('sqlite'): # maybe others?
if self.type in ('integer','bigint'):
result_type = 'integer'
elif self.type in ['date','time','datetime','double','float']:
result_type = 'double'
else:
raise SyntaxError(subtraction operation not supported for 
type)
else:
result_type = self.type



On Wednesday, March 6, 2013 11:55:20 AM UTC-5, Massimo Di Pierro wrote:

 According to the code:

 if self.type in ('integer','bigint'):
 result_type = 'integer'
 elif self.type in ['date','time','datetime','double','float']:
 result_type = 'double'
 else:
 raise SyntaxError(subtraction operation not supported for 
 type)

 what is the type of db.production_jobs.quantity_on_hand?

 On Wednesday, 6 March 2013 08:45:20 UTC-6, Cliff Kachinske wrote:

 V 2.4.2

 Apparently I can add a negative number in an update expression but I cannot 
 subtract a positive number.  


 Snippet:

 delta = new_allocation - record.quantity_allocated 
 db(db.production_jobs.id==record.production_job_id).update(
 quantity_on_hand=db.production_jobs.quantity_on_hand - delta # 
 subtraction.  DAL will not like it
 )

 Snippet raises this exception:

 File 
 /home/cjk/pybin/w-2-4-2/web2py/applications/Inventory/controllers/customer_order_product_lots.py,
  line 70, in update_lot_record
  quantity_on_hand=db.production_jobs.quantity_on_hand - delta
  File /home/cjk/pybin/w-2-4-2/web2py/gluon/dal.py, line 8820, in __sub__
  raise SyntaxError(subtraction operation not supported for type)
 SyntaxError: subtraction operation not supported for type

 Hackish workaround:

 delta = -(new_allocation - record.quantity_allocated) # flip value to 
 negative
 db(db.production_jobs.id==record.production_job_id).update(
 quantity_on_hand=db.production_jobs.quantity_on_hand + delta # add 
 negative number.  DAL okay with this
 )


 Is this the expected behavior?

 Or am I missing something?




-- 

--- 
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/groups/opt_out.