Skip to content

Instantly share code, notes, and snippets.

@mbenedettini
Created August 1, 2012 16:44
Show Gist options
  • Save mbenedettini/3228630 to your computer and use it in GitHub Desktop.
Save mbenedettini/3228630 to your computer and use it in GitHub Desktop.
Patio patch to fix default value detection
--- /home/mariano/work/patio/lib/adapters/mysql.js 2012-07-31 17:14:08.146130970 -0300
+++ ./node_modules/patio/lib/adapters/mysql.js 2012-08-01 13:39:14.631535958 -0300
@@ -809,10 +809,16 @@
ret.autoIncrement = e.match(/auto_increment/i) !== null;
ret.allowNull = allowNull.match(/Yes/i) !== null;
ret.primaryKey = key.match(/PRI/i) !== null;
- ret["default"] = row[m("Default")];
- if (isEmpty(row["default"])) {
- row["default"] = null;
+
+ // Default value
+ ret.default = row[m("Default")];
+ if (isEmpty(ret.default)) {
+ ret.default = null;
}
+ else if(Buffer.isBuffer(ret.default)) {
+ ret.default = ret.default.toString();
+ }
+
ret.dbType = row[m("Type")];
if (Buffer.isBuffer(ret.dbType)) {
//handle case for field type being returned at 252 (i.e. BLOB)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment