File tree Expand file tree Collapse file tree 4 files changed +29
-6
lines changed
Expand file tree Collapse file tree 4 files changed +29
-6
lines changed Original file line number Diff line number Diff line change @@ -128,11 +128,12 @@ class SqliteCacheStore {
128128 this . #db = new DatabaseSync ( opts ?. location ?? ':memory:' )
129129
130130 /**
131+ * @see https://sqlite.org/schematab.html#interpretation_of_the_schema_table
131132 * @type {{
132133 * type: 'table' | 'index' | (string & {}),
133134 * name: string,
134135 * tbl_name: string,
135- * sql: number
136+ * sql: string
136137 * }[] }
137138 */
138139 const items = this . #db. prepare (
Original file line number Diff line number Diff line change 1313 ( env . NODE_OPTIONS && env . NODE_OPTIONS . match ( / e x p e r i m e n t a l ( - | _ ) s q l i t e / ) ) ||
1414 execArgv . some ( argv => argv . match ( / e x p e r i m e n t a l ( - | _ ) s q l i t e / ) )
1515) {
16+ const { DatabaseSync } = require ( 'node:sqlite' )
1617 const SqliteCacheStore = require ( '../../lib/cache/sqlite-cache-store.js' )
1718
1819 cacheStoreTests ( SqliteCacheStore )
8182 rawTrailers : requestTrailers
8283 } )
8384 } )
85+
86+ test ( 'SqliteCacheStore ignores unknown types tied to cacheInterceptor table when sql is right' , async ( t ) => {
87+ const sqliteLocation = 'cache-interceptor.sqlite'
88+
89+ t . after ( async ( ) => {
90+ await rm ( sqliteLocation )
91+ } )
92+
93+ // eslint-disable-next-line no-unused-vars
94+ const _ = new SqliteCacheStore ( {
95+ location : sqliteLocation
96+ } )
97+
98+ const db = new DatabaseSync ( sqliteLocation )
99+ db . exec ( 'CREATE VIEW cacheInterceptorView AS SELECT * FROM cacheInterceptor' )
100+
101+ // eslint-disable-next-line no-unused-vars
102+ const _2 = new SqliteCacheStore ( {
103+ location : sqliteLocation
104+ } )
105+
106+ equal (
107+ db . prepare ( 'SELECT * FROM sqlite_master WHERE type = \'view\' AND name = \'cacheInterceptorView\'' ) . all ( ) . length ,
108+ 1
109+ )
110+ } )
84111}
85112
86113/**
Original file line number Diff line number Diff line change @@ -65,7 +65,6 @@ expectAssignable<CacheInterceptor.MemoryCacheStoreOpts>({
6565expectAssignable < CacheInterceptor . SqliteCacheStoreOpts > ( { } )
6666expectAssignable < CacheInterceptor . SqliteCacheStoreOpts > ( {
6767 location : '' ,
68- maxEntries : 0 ,
6968 maxEntrySize : 0 ,
7069 errorCallback : ( _ : Error ) => { }
7170} )
Original file line number Diff line number Diff line change @@ -101,10 +101,6 @@ declare namespace CacheHandler {
101101 * @default ':memory:'
102102 */
103103 location ?: string
104- /**
105- * @default Infinity
106- */
107- maxEntries ?: number
108104 /**
109105 * @default Infinity
110106 */
You can’t perform that action at this time.
0 commit comments