summaryrefslogtreecommitdiffstats
path: root/WebCore/storage/IDBKey.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/storage/IDBKey.cpp')
-rw-r--r--WebCore/storage/IDBKey.cpp58
1 files changed, 58 insertions, 0 deletions
diff --git a/WebCore/storage/IDBKey.cpp b/WebCore/storage/IDBKey.cpp
index 50c4c46..6ae79ba 100644
--- a/WebCore/storage/IDBKey.cpp
+++ b/WebCore/storage/IDBKey.cpp
@@ -28,6 +28,7 @@
#if ENABLE(INDEXED_DATABASE)
+#include "SQLiteStatement.h"
#include "SerializedScriptValue.h"
namespace WebCore {
@@ -72,6 +73,63 @@ bool IDBKey::isEqual(IDBKey* other)
return false;
}
+String IDBKey::whereSyntax() const
+{
+ switch (m_type) {
+ case IDBKey::StringType:
+ return "keyString = ?";
+ case IDBKey::NumberType:
+ return "keyNumber = ?";
+ // FIXME: Implement date.
+ case IDBKey::NullType:
+ return "keyString IS NULL AND keyDate IS NULL AND keyNumber IS NULL";
+ }
+
+ ASSERT_NOT_REACHED();
+ return "";
+}
+
+// Returns the number of items bound.
+int IDBKey::bind(SQLiteStatement& query, int column) const
+{
+ switch (m_type) {
+ case IDBKey::StringType:
+ query.bindText(column, m_string);
+ return 1;
+ case IDBKey::NumberType:
+ query.bindInt(column, m_number);
+ return 1;
+ case IDBKey::NullType:
+ return 0;
+ }
+
+ ASSERT_NOT_REACHED();
+ return 0;
+}
+
+void IDBKey::bindWithNulls(SQLiteStatement& query, int baseColumn) const
+{
+ switch (m_type) {
+ case IDBKey::StringType:
+ query.bindText(baseColumn + 0, m_string);
+ query.bindNull(baseColumn + 1);
+ query.bindNull(baseColumn + 2);
+ break;
+ case IDBKey::NumberType:
+ query.bindNull(baseColumn + 0);
+ query.bindNull(baseColumn + 1);
+ query.bindInt(baseColumn + 2, m_number);
+ break;
+ case IDBKey::NullType:
+ query.bindNull(baseColumn + 0);
+ query.bindNull(baseColumn + 1);
+ query.bindNull(baseColumn + 2);
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+}
+
} // namespace WebCore
#endif