summaryrefslogtreecommitdiffstats
path: root/WebCore/storage/IDBKey.cpp
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2010-09-29 17:32:26 +0100
committerSteve Block <steveblock@google.com>2010-09-29 17:35:08 +0100
commit68513a70bcd92384395513322f1b801e7bf9c729 (patch)
tree161b50f75a5921d61731bb25e730005994fcec85 /WebCore/storage/IDBKey.cpp
parentfd5c6425ce58eb75211be7718d5dee960842a37e (diff)
downloadexternal_webkit-68513a70bcd92384395513322f1b801e7bf9c729.zip
external_webkit-68513a70bcd92384395513322f1b801e7bf9c729.tar.gz
external_webkit-68513a70bcd92384395513322f1b801e7bf9c729.tar.bz2
Merge WebKit at r67908: Initial merge by Git
Change-Id: I43a553e7b3299b28cb6ee8aa035ed70fe342b972
Diffstat (limited to 'WebCore/storage/IDBKey.cpp')
-rw-r--r--WebCore/storage/IDBKey.cpp58
1 files changed, 54 insertions, 4 deletions
diff --git a/WebCore/storage/IDBKey.cpp b/WebCore/storage/IDBKey.cpp
index 6ae79ba..3eec36c 100644
--- a/WebCore/storage/IDBKey.cpp
+++ b/WebCore/storage/IDBKey.cpp
@@ -54,6 +54,22 @@ IDBKey::~IDBKey()
{
}
+PassRefPtr<IDBKey> IDBKey::fromQuery(SQLiteStatement& query, int baseColumn)
+{
+ if (!query.isColumnNull(baseColumn))
+ return IDBKey::create(query.getColumnText(baseColumn));
+
+ if (!query.isColumnNull(baseColumn + 1)) {
+ ASSERT_NOT_REACHED(); // FIXME: Implement date.
+ return IDBKey::create();
+ }
+
+ if (!query.isColumnNull(baseColumn + 2))
+ return IDBKey::create(query.getColumnInt(baseColumn + 2));
+
+ return IDBKey::create(); // Null.
+}
+
bool IDBKey::isEqual(IDBKey* other)
{
if (!other || other->m_type != m_type)
@@ -73,22 +89,56 @@ bool IDBKey::isEqual(IDBKey* other)
return false;
}
-String IDBKey::whereSyntax() const
+String IDBKey::whereSyntax(String qualifiedTableName) const
{
switch (m_type) {
case IDBKey::StringType:
- return "keyString = ?";
+ return qualifiedTableName + "keyString = ? ";
case IDBKey::NumberType:
- return "keyNumber = ?";
+ return qualifiedTableName + "keyNumber = ? ";
// FIXME: Implement date.
case IDBKey::NullType:
- return "keyString IS NULL AND keyDate IS NULL AND keyNumber IS NULL";
+ return qualifiedTableName + "keyString IS NULL AND " + qualifiedTableName + "keyDate IS NULL AND " + qualifiedTableName + "keyNumber IS NULL ";
}
ASSERT_NOT_REACHED();
return "";
}
+String IDBKey::leftCursorWhereFragment(String comparisonOperator, String qualifiedTableName)
+{
+ switch (m_type) {
+ case StringType:
+ return "? " + comparisonOperator + " " + qualifiedTableName + "keyString AND ";
+ // FIXME: Implement date.
+ case NumberType:
+ return "(? " + comparisonOperator + " " + qualifiedTableName + "keyNumber OR NOT " + qualifiedTableName + "keyString IS NULL OR NOT " + qualifiedTableName + "keyDate IS NULL) AND ";
+ case NullType:
+ if (comparisonOperator == "<")
+ return "NOT(" + qualifiedTableName + "keyString IS NULL AND " + qualifiedTableName + "keyDate IS NULL AND " + qualifiedTableName + "keyNumber IS NULL) AND ";
+ return ""; // If it's =, the upper bound half will do the constraining. If it's <=, then that's a no-op.
+ }
+ ASSERT_NOT_REACHED();
+ return "";
+}
+
+String IDBKey::rightCursorWhereFragment(String comparisonOperator, String qualifiedTableName)
+{
+ switch (m_type) {
+ case StringType:
+ return "(" + qualifiedTableName + "keyString " + comparisonOperator + " ? OR " + qualifiedTableName + "keyString IS NULL) AND ";
+ // FIXME: Implement date.
+ case NumberType:
+ return "(" + qualifiedTableName + "keyNumber " + comparisonOperator + " ? OR " + qualifiedTableName + "keyNumber IS NULL) AND " + qualifiedTableName + "keyString IS NULL AND " + qualifiedTableName + "keyDate IS NULL AND ";
+ case NullType:
+ if (comparisonOperator == "<")
+ return "0 != 0 AND ";
+ return qualifiedTableName + "keyString IS NULL AND " + qualifiedTableName + "keyDate IS NULL AND " + qualifiedTableName + "keyNumber IS NULL AND ";
+ }
+ ASSERT_NOT_REACHED();
+ return "";
+}
+
// Returns the number of items bound.
int IDBKey::bind(SQLiteStatement& query, int column) const
{