Reviewed by Tim Hatcher.
Fixes: http://bugs.webkit.org/show_bug.cgi?id=17191
HTML5: Client-side database queries should return values of type number
Test: storage/sql-data-types.html
Make the DB queries return a value as a number if it was inserted
as a number to the database.
* platform/sql/SQLiteStatement.cpp:
(WebCore::SQLiteStatement::getColumnValue): new member function to return SQLValues
* platform/sql/SQLiteStatement.h:
* storage/SQLStatement.cpp:
(WebCore::SQLStatement::execute): use getColumnValue instead of getColumnText
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@30087
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2008-02-06 Kimmo Kinnunen <kimmok@iki.fi>
+
+ Reviewed by Tim Hatcher.
+
+ Test for: http://bugs.webkit.org/show_bug.cgi?id=17191
+ HTML5: Client-side database queries should return values of type number
+
+ * storage/sql-data-types-expected.txt: Added.
+ * storage/sql-data-types.html: Added.
+ * storage/sql-data-types.js: Added.
+
2008-02-07 Dan Bernstein <mitz@apple.com>
Reviewed by Dave Hyatt.
+2008-02-06 Kimmo Kinnunen <kimmok@iki.fi>
+
+ Reviewed by Tim Hatcher.
+
+ Fixes: http://bugs.webkit.org/show_bug.cgi?id=17191
+ HTML5: Client-side database queries should return values of type number
+ Test: storage/sql-data-types.html
+
+ Make the DB queries return a value as a number if it was inserted
+ as a number to the database.
+ * platform/sql/SQLiteStatement.cpp:
+ (WebCore::SQLiteStatement::getColumnValue): new member function to return SQLValues
+ * platform/sql/SQLiteStatement.h:
+ * storage/SQLStatement.cpp:
+ (WebCore::SQLStatement::execute): use getColumnValue instead of getColumnText
+
2008-02-07 Ada Chan <adachan@apple.com>
<rdar://problem/5292433> certificate authentication support broken in Safari 3.0
return String();
return String(reinterpret_cast<const UChar*>(sqlite3_column_name16(m_statement, col)));
}
-
+
+SQLValue SQLiteStatement::getColumnValue(int col)
+{
+ ASSERT(col >= 0);
+ if (!m_statement)
+ if (prepareAndStep() != SQLITE_ROW)
+ return SQLValue();
+ if (columnCount() <= col)
+ return SQLValue();
+
+ // SQLite is typed per value. optional column types are
+ // "(mostly) ignored"
+ sqlite3_value* value = sqlite3_column_value(m_statement, col);
+ switch (sqlite3_value_type(value)) {
+ case SQLITE_INTEGER: // SQLValue and JS don't represent integers, so use FLOAT -case
+ case SQLITE_FLOAT:
+ return SQLValue(sqlite3_value_double(value));
+ case SQLITE_BLOB: // SQLValue and JS don't represent blobs, so use TEXT -case
+ case SQLITE_TEXT:
+ return SQLValue(String(reinterpret_cast<const UChar*>(sqlite3_value_text16(value))));
+ case SQLITE_NULL:
+ return SQLValue();
+ default:
+ break;
+ }
+ ASSERT_NOT_REACHED();
+ return SQLValue();
+}
+
String SQLiteStatement::getColumnText(int col)
{
ASSERT(col >= 0);
int columnCount();
String getColumnName(int col);
+ SQLValue getColumnValue(int col);
String getColumnText(int col);
double getColumnDouble(int col);
int getColumnInt(int col);
rows->addColumn(statement.getColumnName(i));
do {
- for (int i = 0; i < columnCount; i++) {
- // FIXME: Look at the column type?
- rows->addResult(statement.getColumnText(i));
- }
+ for (int i = 0; i < columnCount; i++)
+ rows->addResult(statement.getColumnValue(i));
result = statement.step();
} while (result == SQLResultRow);