ZF-7759: Some Mssql Number types fail to insert due to quotes
Description
Mssql 2008 fails to insert using the insert method due to quotes. Mssql can convert Double and Int but throws an error for money and small money types.
Ex:
Table
CREATE TABLE dbo.testMoney
(
id int NOT NULL IDENTITY (1, 1),
paid money NOT NULL
) ON [PRIMARY]
GO
Insert.php
class MoneyTable extends Zend_Db_Table_Abstract
{
protected $_name = "testMoney";
}
$db = new MoneyTable;
$data = array('paid' => 5.25);
$db->insert($data);
Query Created (taken from sql profiler)
INSERT INTO "testMoney" ("paid") VALUES ('5.25')
This causes Sql Server to fail since the 5.25 is in quotes. The query should be:
INSERT INTO "testMoney" ("paid") VALUES (5.25)
Comments
Posted by Ralph Schindler (ralph) on 2009-09-17T16:36:35.000+0000
What adapter & driver are you using?
Posted by Chuck Reeves (creeves1982) on 2009-10-05T09:04:35.000+0000
freedts on ubuntu. I adjusted the Zend_Db_Adapter_Pdo_Mssql and changed the _pdotype to be dblib.
Posted by Chuck Reeves (creeves1982) on 2009-12-18T11:58:15.000+0000
This appears to be an issue inside of MSSQL. I am still looking into what the issue with MSSQL to find out why this is failing. I actually found that on a table of mine with 4 money fields, it wanted me to CAST for only 1 out of those 4 fields.
Posted by Rob Allen (rob) on 2012-11-20T20:53:22.000+0000
Bulk change of all issues last updated before 1st January 2010 as "Won't Fix".
Feel free to re-open and provide a patch if you want to fix this issue.