Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sqlitecloud/drivers",
"version": "1.0.345",
"version": "1.0.354",
"description": "SQLiteCloud drivers for Typescript/Javascript in edge, web and node clients",
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
Expand Down
4 changes: 4 additions & 0 deletions src/drivers/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,10 @@ export function popData(buffer: Buffer): { data: SQLiteCloudDataTypes | SQLiteCl

/** Format a command to be sent via SCSP protocol */
export function formatCommand(command: SQLiteCloudCommand): string {
// core returns null if there's a space after the semi column
// we want to maintain a compatibility with the standard sqlite3 driver
command.query = command.query.trim()

if (command.parameters && command.parameters.length > 0) {
// by SCSP the string paramenters in the array are zero-terminated
return serializeCommand([command.query, ...(command.parameters || [])], true)
Expand Down
19 changes: 9 additions & 10 deletions test/statement.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ it('Statement.each without bindings', done => {
statement.each(4, rowCallback, completeCallback)
})


it('Statement.get', done => {
const chinook = getChinookDatabase()
expect(chinook).toBeDefined()
Expand Down Expand Up @@ -226,7 +225,6 @@ it('Statement.get without bindings', done => {
})
})


it('Statement.run', done => {
const chinook = getChinookDatabase()
expect(chinook).toBeDefined()
Expand Down Expand Up @@ -268,7 +266,7 @@ it('Statement.run - insert', done => {
})
})

it('Statement.run - insert with empty space after semicolon returns null', done => {
it("Statement.run - insert with empty space after semicolon shouldn't return null", done => {
// create simple "people" database that we can write in...
const database = getTestingDatabase(error => {
expect(error).toBeNull()
Expand All @@ -277,14 +275,14 @@ it('Statement.run - insert with empty space after semicolon returns null', done

// @ts-ignore
statement.run('John Wayne', 73, 'Horse Riding', (error, results) => {
expect(results).toBeNull()
expect(results).not.toBeNull()
expect(results).toBe('OK')

done()
})
})
})


it('Statement.run - update', done => {
const database = getTestingDatabase(error => {
expect(error).toBeNull()
Expand All @@ -300,15 +298,16 @@ it('Statement.run - update', done => {
})
})

it('Statement.run - update with empty space after semicolon returns null', done => {
it("Statement.run - update with empty space after semicolon shouldn't return null", done => {
const database = getTestingDatabase(error => {
expect(error).toBeNull()

const statement = database.prepare('UPDATE people SET name= ? WHERE id = ?; ')

// @ts-ignore
statement.run('John Wayne', 1, (error, results) => {
expect(results).toBeNull()
expect(results).not.toBeNull()
expect(results).toBe('OK')

done()
})
Expand All @@ -330,18 +329,18 @@ it('Statement.run - delete', done => {
})
})

it('Statement.run - delete with empty space after semicolon returns null', done => {
it("Statement.run - delete with empty space after semicolon shouldn't return null", done => {
const database = getTestingDatabase(error => {
expect(error).toBeNull()

const statement = database.prepare('DELETE FROM people WHERE id = ?; ')

// @ts-ignore
statement.run(1, (error, results) => {
expect(results).toBeNull()
expect(results).not.toBeNull()
expect(results).toBe('OK')

done()
})
})
})

Loading