Skip to content

Commit 9a397b3

Browse files
committed
Build sqlite3 with json1 extension
1 parent 5cfa4f6 commit 9a397b3

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

tensorflow/core/lib/db/sqlite_test.cc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,19 @@ TEST_F(SqliteTest, InsertAndSelectDouble) {
7373
EXPECT_EQ(1, stmt.ColumnInt(1));
7474
}
7575

76+
TEST_F(SqliteTest, Json1Extension) {
77+
string s1 = "{\"key\": 42}";
78+
string s2 = "{\"key\": \"value\"}";
79+
auto stmt = db_->PrepareOrDie("INSERT INTO T (a, b) VALUES (?, ?)");
80+
stmt.BindText(1, s1);
81+
stmt.BindText(2, s2);
82+
TF_ASSERT_OK(stmt.StepAndReset());
83+
stmt = db_->PrepareOrDie("SELECT json_extract(a, '$.key'), json_extract(b, '$.key') FROM T");
84+
TF_ASSERT_OK(stmt.Step(&is_done_));
85+
EXPECT_EQ(42, stmt.ColumnInt(0));
86+
EXPECT_EQ("value", stmt.ColumnString(1));
87+
}
88+
7689
TEST_F(SqliteTest, NulCharsInString) {
7790
string s; // XXX: Want to write {2, '\0'} but not sure why not.
7891
s.append(static_cast<size_t>(2), '\0');

third_party/sqlite.BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ licenses(["unencumbered"]) # Public Domain
55

66
SQLITE_COPTS = [
77
"-Os",
8+
"-DSQLITE_ENABLE_JSON1",
89
"-DHAVE_DECL_STRERROR_R=1",
910
"-DHAVE_STDINT_H=1",
1011
"-DHAVE_INTTYPES_H=1",

0 commit comments

Comments
 (0)