Skip to content

Commit dde4b89

Browse files
committed
fix: handle columns not in pragma_table_info
1 parent e1849a7 commit dde4b89

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/inferQueryResult.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ export function inferQueryResult(
7575
});
7676

7777
if (!columnData) {
78-
throw new Error("Unable to get column data");
78+
columnTypes.set(column.name, ColumnType.Unknown);
79+
continue;
7980
}
8081

8182
let type = columnData.type;

tests/inferQueryResult.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,3 +199,16 @@ it("should support query as column", () => {
199199
{ name: "id", type: ColumnType.String | ColumnType.Null },
200200
]);
201201
});
202+
203+
it("should support selecting rowid, oid, and _rowid_", () => {
204+
const result = testInferQueryResult(
205+
"CREATE TABLE foo (name text)",
206+
"SELECT rowid as rowid, oid as oid, _rowid_ as _rowid_ FROM foo",
207+
);
208+
209+
expect(result).toStrictEqual<typeof result>([
210+
{ name: "rowid", type: ColumnType.Unknown },
211+
{ name: "oid", type: ColumnType.Unknown },
212+
{ name: "_rowid_", type: ColumnType.Unknown },
213+
]);
214+
});

0 commit comments

Comments
 (0)