tagomoris / mysql2-cs-bind Goto Github PK
View Code? Open in Web Editor NEW'mysql2' extension to add pseudo prepared statement
License: MIT License
'mysql2' extension to add pseudo prepared statement
License: MIT License
With a table as:
CREATE TABLE IF NOT EXISTS tests (
bool BOOLEAN NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
Following xquery
db.xquery('INSERT INTO tests (bool) VALUES (?)', true)
raises an error as:
lib/ruby/gems/2.4.0/gems/mysql2-0.5.2/lib/mysql2/client.rb:131:in `_query': Incorrect integer value: 'true' for column 'bool' at row 1 (Mysql2::Error)
from lib/ruby/gems/2.4.0/gems/mysql2-0.5.2/lib/mysql2/client.rb:131:in `block in query'
from lib/ruby/gems/2.4.0/gems/mysql2-0.5.2/lib/mysql2/client.rb:130:in `handle_interrupt'
from lib/ruby/gems/2.4.0/gems/mysql2-0.5.2/lib/mysql2/client.rb:130:in `query'
from lib/ruby/gems/2.4.0/gems/mysql2-cs-bind-0.0.6/lib/mysql2-cs-bind.rb:14:in `xquery'
because it executes
INSERT INTO tests (bool) VALUES ('true')
Note that
INSERT INTO tests (bool) VALUES (true)
or
INSERT INTO tests (bool) VALUES ('1')
works
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' ' [xquery parameter] ' ' at line 1 (Mysql2::Error)
Fixed by deleting the appended ' ' in front and after the parameters.
Took my 6 hours to try to get a prepared statement going and then I just decided to try to fix your gem instead. That took 10 seconds. Programmer lyf :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.