Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
node-sqlite3
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
俞永鹏
node-sqlite3
Commits
a8c34ea4
Unverified
Commit
a8c34ea4
authored
Dec 13, 2018
by
Kewde
Committed by
GitHub
Dec 13, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1078 from gms1/add-open-flags
fix #1032: add constants for file open
parents
5bb0dc0e
802afaf2
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
0 deletions
+64
-0
node_sqlite3.cc
src/node_sqlite3.cc
+3
-0
constants.test.js
test/constants.test.js
+3
-0
open_close.test.js
test/open_close.test.js
+58
-0
No files found.
src/node_sqlite3.cc
View file @
a8c34ea4
...
...
@@ -22,6 +22,9 @@ NAN_MODULE_INIT(RegisterModule) {
DEFINE_CONSTANT_INTEGER
(
target
,
SQLITE_OPEN_READWRITE
,
OPEN_READWRITE
);
DEFINE_CONSTANT_INTEGER
(
target
,
SQLITE_OPEN_CREATE
,
OPEN_CREATE
);
DEFINE_CONSTANT_INTEGER
(
target
,
SQLITE_OPEN_FULLMUTEX
,
OPEN_FULLMUTEX
);
DEFINE_CONSTANT_INTEGER
(
target
,
SQLITE_OPEN_URI
,
OPEN_URI
);
DEFINE_CONSTANT_INTEGER
(
target
,
SQLITE_OPEN_SHAREDCACHE
,
OPEN_SHAREDCACHE
);
DEFINE_CONSTANT_INTEGER
(
target
,
SQLITE_OPEN_PRIVATECACHE
,
OPEN_PRIVATECACHE
);
DEFINE_CONSTANT_STRING
(
target
,
SQLITE_VERSION
,
VERSION
);
#ifdef SQLITE_SOURCE_ID
DEFINE_CONSTANT_STRING
(
target
,
SQLITE_SOURCE_ID
,
SOURCE_ID
);
...
...
test/constants.test.js
View file @
a8c34ea4
...
...
@@ -6,7 +6,10 @@ describe('constants', function() {
assert
.
ok
(
sqlite3
.
OPEN_READONLY
===
1
);
assert
.
ok
(
sqlite3
.
OPEN_READWRITE
===
2
);
assert
.
ok
(
sqlite3
.
OPEN_CREATE
===
4
);
assert
.
ok
(
sqlite3
.
OPEN_URI
===
0x00000040
);
assert
.
ok
(
sqlite3
.
OPEN_FULLMUTEX
===
0x00010000
);
assert
.
ok
(
sqlite3
.
OPEN_SHAREDCACHE
===
0x00020000
);
assert
.
ok
(
sqlite3
.
OPEN_PRIVATECACHE
===
0x00040000
);
});
it
(
'should have the right error flags'
,
function
()
{
...
...
test/open_close.test.js
View file @
a8c34ea4
...
...
@@ -31,6 +31,64 @@ describe('open/close', function() {
});
});
describe
(
'open and close non-existant shared database'
,
function
()
{
before
(
function
()
{
helper
.
deleteFile
(
'test/tmp/test_create_shared.db'
);
});
var
db
;
it
(
'should open the database'
,
function
(
done
)
{
db
=
new
sqlite3
.
Database
(
'file:./test/tmp/test_create_shared.db'
,
sqlite3
.
OPEN_URI
|
sqlite3
.
OPEN_SHAREDCACHE
|
sqlite3
.
OPEN_READWRITE
|
sqlite3
.
OPEN_CREATE
,
done
);
});
it
(
'should close the database'
,
function
(
done
)
{
db
.
close
(
done
);
});
it
(
'should have created the file'
,
function
()
{
assert
.
fileExists
(
'test/tmp/test_create_shared.db'
);
});
after
(
function
()
{
helper
.
deleteFile
(
'test/tmp/test_create_shared.db'
);
});
});
(
sqlite3
.
VERSION_NUMBER
<
3008000
?
describe
.
skip
:
describe
)(
'open and close shared memory database'
,
function
()
{
var
db1
;
var
db2
;
it
(
'should open the first database'
,
function
(
done
)
{
db1
=
new
sqlite3
.
Database
(
'file:./test/tmp/test_memory.db?mode=memory'
,
sqlite3
.
OPEN_URI
|
sqlite3
.
OPEN_SHAREDCACHE
|
sqlite3
.
OPEN_READWRITE
|
sqlite3
.
OPEN_CREATE
,
done
);
});
it
(
'should open the second database'
,
function
(
done
)
{
db2
=
new
sqlite3
.
Database
(
'file:./test/tmp/test_memory.db?mode=memory'
,
sqlite3
.
OPEN_URI
|
sqlite3
.
OPEN_SHAREDCACHE
|
sqlite3
.
OPEN_READWRITE
|
sqlite3
.
OPEN_CREATE
,
done
);
});
it
(
'first database should set the user_version'
,
function
(
done
)
{
db1
.
exec
(
'PRAGMA user_version=42'
,
done
);
});
it
(
'second database should get the user_version'
,
function
(
done
)
{
db2
.
get
(
'PRAGMA user_version'
,
function
(
err
,
row
)
{
if
(
err
)
throw
err
;
assert
.
equal
(
row
.
user_version
,
42
);
done
();
});
});
it
(
'should close the first database'
,
function
(
done
)
{
db1
.
close
(
done
);
});
it
(
'should close the second database'
,
function
(
done
)
{
db2
.
close
(
done
);
});
});
it
(
'should not be unable to open an inaccessible database'
,
function
(
done
)
{
// NOTE: test assumes that the user is not allowed to create new files
// in /usr/bin.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment