From 21a2188caa9951f34a0fe73a31a882c20aac6668 Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Mon, 25 Oct 2010 00:17:53 +0000 Subject: [PATCH] move getSQLDataType to Z.DB --- chrome/content/zotero/xpcom/data/item.js | 4 ++-- chrome/content/zotero/xpcom/db.js | 24 ++++++++++++++++++++++++ chrome/content/zotero/xpcom/utilities.js | 24 ------------------------ 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js index f339a9243c..97e696713d 100644 --- a/chrome/content/zotero/xpcom/data/item.js +++ b/chrome/content/zotero/xpcom/data/item.js @@ -1265,7 +1265,7 @@ Zotero.Item.prototype.save = function() { value = Zotero.DB.transactionDateTime; } - var dataType = ZU.getSQLDataType(value); + var dataType = Zotero.DB.getSQLDataType(value); switch (dataType) { case 32: @@ -1598,7 +1598,7 @@ Zotero.Item.prototype.save = function() { value = Zotero.DB.transactionDateTime; } - var dataType = ZU.getSQLDataType(value); + var dataType = Zotero.DB.getSQLDataType(value); switch (dataType) { case 32: diff --git a/chrome/content/zotero/xpcom/db.js b/chrome/content/zotero/xpcom/db.js index 12e00b49b4..1753d3454b 100644 --- a/chrome/content/zotero/xpcom/db.js +++ b/chrome/content/zotero/xpcom/db.js @@ -1010,6 +1010,30 @@ Zotero.DBConnection.prototype.stopDummyStatement = function () { } +/** + * Determine the necessary data type for SQLite parameter binding + * + * @return int 0 for string, 32 for int32, 64 for int64 + */ +Zotero.DBConnection.prototype.getSQLDataType = function(value) { + var strVal = value + ''; + if (strVal.match(/^[1-9]+[0-9]*$/)) { + // These upper bounds also specified in Zotero.DB + // + // Store as 32-bit signed integer + if (value <= 2147483647) { + return 32; + } + // Store as 64-bit signed integer + // 2^53 is JS's upper-bound for decimal integers + else if (value < 9007199254740992) { + return 64; + } + } + return 0; +} + + ///////////////////////////////////////////////////////////////// // // Private methods diff --git a/chrome/content/zotero/xpcom/utilities.js b/chrome/content/zotero/xpcom/utilities.js index 4ee1ea9049..fe03aeb30c 100644 --- a/chrome/content/zotero/xpcom/utilities.js +++ b/chrome/content/zotero/xpcom/utilities.js @@ -379,30 +379,6 @@ Zotero.Utilities.prototype.rand = function (min, max) { } -/** - * Determine the necessary data type for SQLite parameter binding - * - * @return int 0 for string, 32 for int32, 64 for int64 - */ -Zotero.Utilities.prototype.getSQLDataType = function(value) { - var strVal = value + ''; - if (strVal.match(/^[1-9]+[0-9]*$/)) { - // These upper bounds also specified in Zotero.DB - // - // Store as 32-bit signed integer - if (value <= 2147483647) { - return 32; - } - // Store as 64-bit signed integer - // 2^53 is JS's upper-bound for decimal integers - else if (value < 9007199254740992) { - return 64; - } - } - return 0; -} - - /* * Adapted from http://developer.mozilla.org/en/docs/nsICryptoHash *