Skip to content

Commit 26d4c7d

Browse files
author
SPRINX0\prochazka
committed
2 parents 9b6d810 + 5d25c1b commit 26d4c7d

File tree

4 files changed

+31
-1
lines changed

4 files changed

+31
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "4.10.4",
2+
"version": "4.10.5",
33
"name": "dbgate-query-splitter",
44
"main": "lib/index.js",
55
"typings": "lib/index.d.ts",

sql/pgdump.sql

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
ALTER TABLE public.testxxx OWNER TO postgres;
2+
3+
--
4+
-- Data for Name: Album; Type: TABLE DATA; Schema: public; Owner: postgres
5+
--
6+
7+
COPY public."Album" ("AlbumId", "Title", "ArtistId") FROM stdin;
8+
3 Restless and Wild 2
9+
4 Let There Be Rock 1
10+
5 Big Ones 3
11+
1 For Those About To Rock We Salute You 2
12+
\.
13+

src/splitQueryStream.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ export class SplitQueryStream extends stream.Transform {
6868
trimCommandStartColumn: this.context.trimCommandStartColumn,
6969

7070
wasDataInCommand: this.context.wasDataInCommand,
71+
isCopyFromStdin: this.context.isCopyFromStdin,
72+
isCopyFromStdinCandidate: this.context.isCopyFromStdinCandidate,
7173
};
7274

7375
splitQueryLine(lineContext);
@@ -92,6 +94,8 @@ export class SplitQueryStream extends stream.Transform {
9294
this.context.trimCommandStartColumn = lineContext.trimCommandStartColumn;
9395

9496
this.context.wasDataInCommand = lineContext.wasDataInCommand;
97+
this.context.isCopyFromStdin = lineContext.isCopyFromStdin;
98+
this.context.isCopyFromStdinCandidate = lineContext.isCopyFromStdinCandidate;
9599

96100
this.lineBuffer = '';
97101
}

src/splitterStream.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,16 @@ test('northwind test', async () => {
7373
const output = await streamToArray(splitQueryStream(fileStream, mysqlSplitterOptions));
7474
expect(output['length']).toEqual(29);
7575
});
76+
77+
test('pgdump test', async () => {
78+
console.log(process.cwd());
79+
const fileStream = fs.createReadStream('sql/pgdump.sql', 'utf-8');
80+
const output = await streamToArray(
81+
splitQueryStream(fileStream, {
82+
...postgreSplitterOptions,
83+
copyFromStdin: true,
84+
returnRichInfo: true,
85+
})
86+
);
87+
expect(output['length']).toEqual(7);
88+
});

0 commit comments

Comments
 (0)