Hello,

In SQL 99, doubel quotes reference columns, not values.
MySQL has been broken for years and accepts double quote.

Patch attached.
This fixes a PostgreSQL insert failing.

Please apply.

CommentFileSizeAuthor
patch.diff499 bytesgrub3

Comments

grub3’s picture

The correct SQL code for INSERTS and UPDATEs would be:

  db_query( 
  	'INSERT INTO {uc_bulk_discounts}'
  	. ' ( nid, type, xid, low_qty, high_qty, discount )'
  	. ' VALUES ( %d, \'%s\', %d, %d, %d, %f )',
  	$discount_rule[ 'nid' ], 
  	$discount_rule[ 'type' ], 
  	$discount_rule[ 'xid' ], 
  	$discount_rule[ 'low_qty' ],
    $discount_rule[ 'high_qty' ],
    $discount_rule[ 'discount' ]
  );
  db_query( 'UPDATE {uc_bulk_discounts}'
        . ' SET nid = %d, type = \'%s\', xid = %d,'
        . ' low_qty = %d, high_qty = %d, discount = %f'
        . ' WHERE pdid = %d',
    $discount_rule[ 'nid' ],
    $discount_rule[ 'type' ],
    $discount_rule[ 'xid' ],
    $discount_rule[ 'low_qty' ],
    $discount_rule[ 'high_qty' ],
    $discount_rule[ 'discount' ],
    $discount_rule[ 'pdid' ]
  );

The reference in the developer book is:

MySQLism: avoid using double quotes for alphanumerical values
http://drupal.org/node/555548