| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -15,9 +15,16 @@ | |||
| 15 | 15 | 'defines': [ | |
| 16 | 16 | 'SQLITE_DEFAULT_MEMSTATUS=0', | |
| 17 | 17 | 'SQLITE_ENABLE_COLUMN_METADATA', | |
| 18 | + 'SQLITE_ENABLE_DBSTAT_VTAB', | ||
| 19 | + 'SQLITE_ENABLE_FTS3', | ||
| 20 | + 'SQLITE_ENABLE_FTS3_PARENTHESIS', | ||
| 21 | + 'SQLITE_ENABLE_FTS5', | ||
| 22 | + 'SQLITE_ENABLE_GEOPOLY', | ||
| 18 | 23 | 'SQLITE_ENABLE_MATH_FUNCTIONS', | |
| 24 | + 'SQLITE_ENABLE_PREUPDATE_HOOK', | ||
| 25 | + 'SQLITE_ENABLE_RBU', | ||
| 26 | + 'SQLITE_ENABLE_RTREE', | ||
| 19 | 27 | 'SQLITE_ENABLE_SESSION', | |
| 20 | - 'SQLITE_ENABLE_PREUPDATE_HOOK' | ||
| 21 | 28 | ], | |
| 22 | 29 | 'include_dirs': ['.'], | |
| 23 | 30 | 'sources': [ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,9 +9,16 @@ template("sqlite_gn_build") { | |||
| 9 | 9 | include_dirs = [ "." ] | |
| 10 | 10 | defines = [ | |
| 11 | 11 | "SQLITE_ENABLE_COLUMN_METADATA", | |
| 12 | + "SQLITE_ENABLE_DBSTAT_VTAB", | ||
| 13 | + "SQLITE_ENABLE_FTS3", | ||
| 14 | + "SQLITE_ENABLE_FTS3_PARENTHESIS", | ||
| 15 | + "SQLITE_ENABLE_FTS5", | ||
| 16 | + "SQLITE_ENABLE_GEOPOLY", | ||
| 12 | 17 | "SQLITE_ENABLE_MATH_FUNCTIONS", | |
| 13 | - "SQLITE_ENABLE_SESSION", | ||
| 14 | 18 | "SQLITE_ENABLE_PREUPDATE_HOOK", | |
| 19 | + "SQLITE_ENABLE_RBU", | ||
| 20 | + "SQLITE_ENABLE_RTREE", | ||
| 21 | + "SQLITE_ENABLE_SESSION", | ||
| 15 | 22 | ] | |
| 16 | 23 | } | |
| 17 | 24 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -105,14 +105,6 @@ test('PRAGMAs are supported', (t) => { | |||
| 105 | 105 | ); | |
| 106 | 106 | }); | |
| 107 | 107 | ||
| 108 | - test('math functions are enabled', (t) => { | ||
| 109 | - const db = new DatabaseSync(':memory:'); | ||
| 110 | - t.assert.deepStrictEqual( | ||
| 111 | - db.prepare('SELECT PI() AS pi').get(), | ||
| 112 | - { __proto__: null, pi: 3.141592653589793 }, | ||
| 113 | - ); | ||
| 114 | - }); | ||
| 115 | - | ||
| 116 | 108 | test('Buffer is supported as the database path', (t) => { | |
| 117 | 109 | const db = new DatabaseSync(Buffer.from(nextDb())); | |
| 118 | 110 | t.after(() => { db.close(); }); | |
@@ -142,7 +134,6 @@ test('URL is supported as the database path', (t) => { | |||
| 142 | 134 | ); | |
| 143 | 135 | }); | |
| 144 | 136 | ||
| 145 | - | ||
| 146 | 137 | suite('URI query params', () => { | |
| 147 | 138 | const baseDbPath = nextDb(); | |
| 148 | 139 | const baseDb = new DatabaseSync(baseDbPath); | |
@@ -210,3 +201,134 @@ suite('URI query params', () => { | |||
| 210 | 201 | }); | |
| 211 | 202 | }); | |
| 212 | 203 | }); | |
| 204 | + | ||
| 205 | + suite('SQL APIs enabled at build time', () => { | ||
| 206 | + test('math functions are enabled', (t) => { | ||
| 207 | + const db = new DatabaseSync(':memory:'); | ||
| 208 | + t.assert.deepStrictEqual( | ||
| 209 | + db.prepare('SELECT PI() AS pi').get(), | ||
| 210 | + { __proto__: null, pi: 3.141592653589793 }, | ||
| 211 | + ); | ||
| 212 | + }); | ||
| 213 | + | ||
| 214 | + test('dbstat is enabled', (t) => { | ||
| 215 | + const db = new DatabaseSync(nextDb()); | ||
| 216 | + t.after(() => { db.close(); }); | ||
| 217 | + db.exec(` | ||
| 218 | + CREATE TABLE t1 (key INTEGER PRIMARY KEY); | ||
| 219 | + `); | ||
| 220 | + | ||
| 221 | + t.assert.deepStrictEqual( | ||
| 222 | + db.prepare('SELECT * FROM dbstat WHERE name = \'t1\'').get(), | ||
| 223 | + { | ||
| 224 | + __proto__: null, | ||
| 225 | + mx_payload: 0, | ||
| 226 | + name: 't1', | ||
| 227 | + ncell: 0, | ||
| 228 | + pageno: 2, | ||
| 229 | + pagetype: 'leaf', | ||
| 230 | + path: '/', | ||
| 231 | + payload: 0, | ||
| 232 | + pgoffset: 4096, | ||
| 233 | + pgsize: 4096, | ||
| 234 | + unused: 4088 | ||
| 235 | + }, | ||
| 236 | + ); | ||
| 237 | + }); | ||
| 238 | + | ||
| 239 | + test('fts3 is enabled', (t) => { | ||
| 240 | + const db = new DatabaseSync(':memory:'); | ||
| 241 | + db.exec(` | ||
| 242 | + CREATE VIRTUAL TABLE t1 USING fts3(content TEXT); | ||
| 243 | + INSERT INTO t1 (content) VALUES ('hello world'); | ||
| 244 | + `); | ||
| 245 | + | ||
| 246 | + t.assert.deepStrictEqual( | ||
| 247 | + db.prepare('SELECT * FROM t1 WHERE t1 MATCH \'hello\'').all(), | ||
| 248 | + [ | ||
| 249 | + { __proto__: null, content: 'hello world' }, | ||
| 250 | + ], | ||
| 251 | + ); | ||
| 252 | + }); | ||
| 253 | + | ||
| 254 | + test('fts3 parenthesis', (t) => { | ||
| 255 | + const db = new DatabaseSync(':memory:'); | ||
| 256 | + db.exec(` | ||
| 257 | + CREATE VIRTUAL TABLE t1 USING fts3(content TEXT); | ||
| 258 | + INSERT INTO t1 (content) VALUES ('hello world'); | ||
| 259 | + `); | ||
| 260 | + | ||
| 261 | + t.assert.deepStrictEqual( | ||
| 262 | + db.prepare('SELECT * FROM t1 WHERE content MATCH \'(groupedterm1 OR groupedterm2) OR hello world\'').all(), | ||
| 263 | + [ | ||
| 264 | + { __proto__: null, content: 'hello world' }, | ||
| 265 | + ], | ||
| 266 | + ); | ||
| 267 | + }); | ||
| 268 | + | ||
| 269 | + test('fts4 is enabled', (t) => { | ||
| 270 | + const db = new DatabaseSync(':memory:'); | ||
| 271 | + db.exec(` | ||
| 272 | + CREATE VIRTUAL TABLE t1 USING fts4(content TEXT); | ||
| 273 | + INSERT INTO t1 (content) VALUES ('hello world'); | ||
| 274 | + `); | ||
| 275 | + | ||
| 276 | + t.assert.deepStrictEqual( | ||
| 277 | + db.prepare('SELECT * FROM t1 WHERE t1 MATCH \'hello\'').all(), | ||
| 278 | + [ | ||
| 279 | + { __proto__: null, content: 'hello world' }, | ||
| 280 | + ], | ||
| 281 | + ); | ||
| 282 | + }); | ||
| 283 | + | ||
| 284 | + test('fts5 is enabled', (t) => { | ||
| 285 | + const db = new DatabaseSync(':memory:'); | ||
| 286 | + db.exec(` | ||
| 287 | + CREATE VIRTUAL TABLE t1 USING fts5(content); | ||
| 288 | + INSERT INTO t1 (content) VALUES ('hello world'); | ||
| 289 | + `); | ||
| 290 | + | ||
| 291 | + t.assert.deepStrictEqual( | ||
| 292 | + db.prepare('SELECT * FROM t1 WHERE t1 MATCH \'hello\'').all(), | ||
| 293 | + [ | ||
| 294 | + { __proto__: null, content: 'hello world' }, | ||
| 295 | + ], | ||
| 296 | + ); | ||
| 297 | + }); | ||
| 298 | + | ||
| 299 | + test('rtree is enabled', (t) => { | ||
| 300 | + const db = new DatabaseSync(':memory:'); | ||
| 301 | + db.exec(` | ||
| 302 | + CREATE VIRTUAL TABLE t1 USING rtree(id, minX, maxX, minY, maxY); | ||
| 303 | + INSERT INTO t1 (id, minX, maxX, minY, maxY) VALUES (1, 0, 1, 0, 1); | ||
| 304 | + `); | ||
| 305 | + | ||
| 306 | + t.assert.deepStrictEqual( | ||
| 307 | + db.prepare('SELECT * FROM t1 WHERE minX < 0.5').all(), | ||
| 308 | + [ | ||
| 309 | + { __proto__: null, id: 1, minX: 0, maxX: 1, minY: 0, maxY: 1 }, | ||
| 310 | + ], | ||
| 311 | + ); | ||
| 312 | + }); | ||
| 313 | + | ||
| 314 | + test('rbu is enabled', (t) => { | ||
| 315 | + const db = new DatabaseSync(':memory:'); | ||
| 316 | + t.assert.deepStrictEqual( | ||
| 317 | + db.prepare('SELECT sqlite_compileoption_used(\'SQLITE_ENABLE_RBU\') as rbu_enabled;').get(), | ||
| 318 | + { __proto__: null, rbu_enabled: 1 }, | ||
| 319 | + ); | ||
| 320 | + }); | ||
| 321 | + | ||
| 322 | + test('geopoly is enabled', (t) => { | ||
| 323 | + const db = new DatabaseSync(':memory:'); | ||
| 324 | + db.exec(` | ||
| 325 | + CREATE VIRTUAL TABLE t1 USING geopoly(a,b,c); | ||
| 326 | + INSERT INTO t1(_shape) VALUES('[[0,0],[1,0],[0.5,1],[0,0]]'); | ||
| 327 | + `); | ||
| 328 | + | ||
| 329 | + t.assert.deepStrictEqual( | ||
| 330 | + db.prepare('SELECT rowid FROM t1 WHERE geopoly_contains_point(_shape, 0, 0)').get(), | ||
| 331 | + { __proto__: null, rowid: 1 }, | ||
| 332 | + ); | ||
| 333 | + }); | ||
| 334 | + }); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments