Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

any-db-adapter-spec

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

any-db-adapter-spec - npm Package Compare versions

Comparing version 2.1.2 to 2.3.0

4

config.js

@@ -8,5 +8,3 @@ var path = require('path')

var config = cc(camelize(argv),
camelize(cc.env('any_db_test_')),
{ adapterPath: process.cwd() })
var config = cc(camelize(argv), camelize(cc.env('any_db_test_')), { adapterPath: process.cwd() })

@@ -13,0 +11,0 @@ var adapterPath = path.resolve(config.get('adapterPath'))

@@ -1,6 +0,9 @@

exports.testProperties = function (adapter, assert) {
exports.testProperties = function(adapter, assert) {
assert.equal(typeof adapter.name, 'string', 'adapter.name is a string')
assert.equal(typeof adapter.createConnection, 'function', 'adapter.createConnection is a function')
assert.equal(
typeof adapter.createConnection,
'function',
'adapter.createConnection is a function',
)
assert.equal(typeof adapter.createQuery, 'function', 'adapter.createQuery is a function')
}
var Queryable = require('./queryable')
exports.testProperties = function (connection, adapter, assert) {
exports.testProperties = function(connection, adapter, assert) {
Queryable.testProperties(connection, adapter, assert, 'connection')

@@ -8,4 +8,4 @@ assert.equal(typeof connection.end, 'function')

exports.testEvents = function (connection, assert) {
connection.on('open', function () {
exports.testEvents = function(connection, assert) {
connection.on('open', function() {
assert.ok(1, 'connection.emit("open")')

@@ -12,0 +12,0 @@ Queryable.testEvents(connection, assert, 'connection')

@@ -1,5 +0,5 @@

exports.Adapter = require('./adapter')
exports.Query = require('./query')
exports.Queryable = require('./queryable')
exports.Adapter = require('./adapter')
exports.Query = require('./query')
exports.Queryable = require('./queryable')
exports.Connection = require('./connection')
exports.ResultSet = require('./result-set')
exports.ResultSet = require('./result-set')
var EventEmitter = require('events').EventEmitter
exports.testProperties = function (query, assert) {
assert.ok(query instanceof EventEmitter, "query is an EventEmitter")
assert.equal(typeof query.text, 'string', 'query.text is a string')
assert.equal(typeof query.values, 'object', 'query.values is an object')
assert.equal(typeof query.pause, 'function', 'query.pause is a function')
exports.testProperties = function(query, assert) {
assert.ok(query instanceof EventEmitter, 'query is an EventEmitter')
assert.equal(typeof query.text, 'string', 'query.text is a string')
assert.equal(typeof query.values, 'object', 'query.values is an object')
assert.equal(typeof query.pause, 'function', 'query.pause is a function')
assert.equal(typeof query.resume, 'function', 'query.resume is a function')
if (query.callback) assert.equal(typeof query.callback, 'function',
'query.callback is a function')
if (query.callback)
assert.equal(typeof query.callback, 'function', 'query.callback is a function')
}
var inOrder = require('assert-in-order')
var EventEmitter = require('events').EventEmitter
exports.testProperties = function (queryable, adapter, test, name) {
exports.testProperties = function(queryable, adapter, test, name) {
name = name || 'queryable'

@@ -12,14 +12,14 @@ test.ok(queryable instanceof EventEmitter, name + ' is an EventEmitter')

exports.testEvents = function (queryable, test, name) {
exports.testEvents = function(queryable, test, name) {
name = name || 'queryable'
test.test(name + '.query events with callbacks', function (test) {
test.test(name + '.query events with callbacks', function(test) {
testEventsWithResults(queryable, test, name)
})
test.test(name + '.query events with no result and no callback', function (test) {
test.test(name + '.query events with no result and no callback', function(test) {
testEventsNoResultsNoCallback(queryable, test, name)
})
test.test(name + '.query events with errors', function (test) {
test.test(name + '.query events with errors', function(test) {
testEventsQueryError(queryable, test, name)

@@ -29,12 +29,12 @@ })

function testEventsWithResults (queryable, test, name) {
var rows = [{val: 1}]
function testEventsWithResults(queryable, test, name) {
var rows = [{ val: 1 }]
var expectations = inOrder(test, {
'query.callback': ['equal', callback, 'query.callback === callback'],
queryEquals: ['equal', 'query is identical'],
fields: ['pass', 'query.emit("fields")'],
rowEquals: ['deepEqual', rows[0], 'got correct row in "data" event'],
noCloseArgs: ['equal', 0, 'No extra arguments to "close" event'],
rowsEqual: ['deepEqual', rows, 'got correct rows in callback'],
noEndArgs: ['equal', 0, 'No extra arguments to "end" event'],
queryEquals: ['equal', 'query is identical'],
fields: ['pass', 'query.emit("fields")'],
rowEquals: ['deepEqual', rows[0], 'got correct row in "data" event'],
noCloseArgs: ['equal', 0, 'No extra arguments to "close" event'],
rowsEqual: ['deepEqual', rows, 'got correct rows in callback'],
noEndArgs: ['equal', 0, 'No extra arguments to "end" event'],
})

@@ -47,19 +47,19 @@

queryable.once('query', function (q) {
queryable.once('query', function(q) {
expectations.queryEquals(q, query)
})
query.on('fields', function () {
query.on('fields', function() {
expectations.fields()
})
query.on('data', function (row) {
query.on('data', function(row) {
expectations.rowEquals(row)
})
query.on('close', function () {
query.on('close', function() {
expectations.noCloseArgs(arguments.length)
})
query.on('end', function () {
query.on('end', function() {
expectations.noEndArgs(arguments.length)

@@ -70,3 +70,3 @@ })

function callback (err, result) {
function callback(err, result) {
if (err) throw err

@@ -77,3 +77,3 @@ expectations.rowsEqual(result.rows)

function testEventsNoResultsNoCallback (queryable, test, name) {
function testEventsNoResultsNoCallback(queryable, test, name) {
test.plan(2)

@@ -83,3 +83,3 @@ var sql = 'SELECT 1 AS val WHERE 0 = 1'

if (queryable.adapter.name == 'mysql') {
sql = 'SELECT 1 AS val FROM INFORMATION_SCHEMA.TABLES WHERE 0 = 1';
sql = 'SELECT 1 AS val FROM INFORMATION_SCHEMA.TABLES WHERE 0 = 1'
}

@@ -90,3 +90,3 @@

query.on('fields', function (fields) {
query.on('fields', function(fields) {
emittedFields = true

@@ -96,7 +96,7 @@ test.ok(Array.isArray(fields), '"fields" event value is an array')

query.on('close', function () {
query.on('close', function() {
test.ok(emittedFields, 'query.emit("close") after query.emit("fields")')
})
query.on('end', function () {
query.on('end', function() {
test.fail('query emitted "end" with no reader!')

@@ -106,10 +106,10 @@ })

function testEventsQueryError (queryable, test, name) {
function testEventsQueryError(queryable, test, name) {
test.plan(5)
var emittedClose = false
, emittedError = false
, emittedEnd = false
var emittedClose = false,
emittedError = false,
emittedEnd = false
var query = queryable.query('not a valid SQL statement', function (err, result) {
var query = queryable.query('not a valid SQL statement', function(err, result) {
//test.ok(emittedClose, 'callback called after query.emit("close")')

@@ -120,3 +120,3 @@ test.ok(!emittedError, 'callback is first listener to query.emit("error")')

query.on('error', function (err) {
query.on('error', function(err) {
emittedError = true

@@ -126,3 +126,3 @@ test.ok(err, 'query.emit("error", err)')

query.on('close', function () {
query.on('close', function() {
emittedClose = true

@@ -132,3 +132,3 @@ test.pass('query.emit("close")')

query.on('end', function () {
query.on('end', function() {
emittedEnd = true

@@ -135,0 +135,0 @@ test.pass('query.emit("end")')

@@ -1,5 +0,5 @@

exports.testProperties = function (result, assert) {
assert.ok(Array.isArray(result.rows), "result.rows is an Array")
assert.ok(Array.isArray(result.fields), "result.fields is an Array")
exports.testProperties = function(result, assert) {
assert.ok(Array.isArray(result.rows), 'result.rows is an Array')
assert.ok(Array.isArray(result.fields), 'result.fields is an Array')
assert.equal(typeof result.rowCount, 'number', 'result.rowCount is a number')
}
// TODO - either find the equivalent on npm, or publish the 1000'th "map over an
// object" package
module.exports = function map (it, fn, ctx) {
module.exports = function map(it, fn, ctx) {
if (typeof it != 'object') {
throw new Error("map called with a non-object")
throw new Error('map called with a non-object')
}
if (arguments.length < 3) ctx = this;
if (arguments.length < 3) ctx = this
var result = []

@@ -9,0 +9,0 @@ for (var k in it) {

{
"name": "any-db-adapter-spec",
"version": "2.1.2",
"version": "2.3.0",
"description": "Specification and test suite for any-db adapters",

@@ -20,13 +20,12 @@ "main": "test-any-db-adapter.js",

"dependencies": {
"arrayify": "~1.0.0",
"assert-in-order": "0.0.3",
"camelize": "~0.1.2",
"config-chain": "~1.1.8",
"for-each": "~0.1.0",
"optimist": "~0.6.0",
"parse-db-url": "2.3.0",
"require-all": "0.0.8",
"camelize": "~0.1.2",
"for-each": "~0.1.0",
"arrayify": "~1.0.0",
"tape": "~2.3.2",
"parse-db-url": "0.0.0",
"assert-in-order": "0.0.3"
"tape": "~2.3.2"
},
"devDependencies": {},
"scripts": {

@@ -33,0 +32,0 @@ "test": "echo \"Error: no test specified\" && exit 1"

@@ -14,8 +14,18 @@ # Any-DB API

- [Queryable][] - a common interface implemented by connections, pools, and
transactions.
- [Connection][] - the "transport" responsible for getting SQL queries to a
database, and streaming results back through a `Query` instance.
- [Query][] - a [Readable][] stream that emits row objects.
- [Queryable][] - a common interface implemented by connections, pools, and
transactions.
- [Connection][] - the "transport" responsible for getting SQL queries to a
database, and streaming results back through a `Query` instance.
- [Query][] - a [Readable][] stream that emits row objects.
## Callbacks
All callbacks used by the API follow convention used in node.js, where first
parameter is an error (or null) and other parameters (if any) depend on use
case.
```ocaml
type Continuation<T> : (Error | null, T) => void
```
## Queryable

@@ -26,3 +36,3 @@

adapter: Adapter
query: (text: String, params: Array?, Continuation<Results>?) => Query
query: (text: String, params?: Array, Continuation<ResultSet>?) => Query
query: (Query) => Query

@@ -33,6 +43,7 @@ }

Known implementations:
- [Connection][Connection]
- [ConnectionPool][ConnectionPool] (external)
- [Transaction][Transaction] (external).
- [Connection][connection]
- [ConnectionPool][connectionpool] (external)
- [Transaction][transaction] (external).
### Queryable.adapter

@@ -46,3 +57,3 @@

```ocaml
(text: String, params: Array?, Continuation<ResultSet>?) => Query
(text: String, params?: Array, Continuation<ResultSet>?) => Query
(Query) => Query

@@ -53,3 +64,3 @@ ```

return a [Query][] object that is a [Readable][] stream of the resulting
rows. If a `Continuation<Results>` is provided the rows returned by the
rows. If a `Continuation<ResultSet>` is provided the rows returned by the
database will be aggregated into a [ResultSet][] which will be passed to the

@@ -62,5 +73,6 @@ continuation after the query has completed.

*Callback-style*
_Callback-style_
```javascript
queryable.query('SELECT * FROM my_table', function (err, res) {
queryable.query('SELECT * FROM my_table', function(err, res) {
if (err) return console.error(err)

@@ -72,8 +84,12 @@ res.rows.forEach(console.log)

*Stream-style*
_Stream-style_
```javascript
queryable.query('SELECT * FROM my_table')
queryable
.query('SELECT * FROM my_table')
.on('error', console.error)
.on('data', console.log)
.on('end', function () { console.log('All done!') })
.on('end', function() {
console.log('All done!')
})
```

@@ -89,3 +105,3 @@

* `query` - a [Query][] object
- `query` - a [Query][] object

@@ -102,5 +118,5 @@ ## Connection

- [any-db-mysql][] (external)
- [any-db-postgres][] (external)
- [any-db-sqlite3][] (external)
- [any-db-mysql][] (external)
- [any-db-postgres][] (external)
- [any-db-sqlite3][] (external)

@@ -133,2 +149,9 @@ Connection objects are obtained using [createConnection][] from [Any-DB][] or

#### Open event
The `'open'` event is emitted when the connection has been established and is
ready to query.
No arguments are passed to event listeners.
#### Close event

@@ -145,11 +168,11 @@

text: String,
values: Array,
callback: null | (Error, Results) => void
values?: Array,
callback?: Continuation<ResultSet>
}
```
`Query` objects are returned by the [Queryable.query][Queryable.query] method,
available on [connections][Connection], [pools][ConnectionPool.query], and
[transactions][Transaction.query]. Queries are instances of [Readable][], and
as such can be [piped][Readable.pipe] through transforms and support backpressure
`Query` objects are returned by the [Queryable.query][queryable.query] method,
available on [connections][connection], [pools][connectionpool.query], and
[transactions][transaction.query]. Queries are instances of [Readable][], and
as such can be [piped][readable.pipe] through transforms and support backpressure
for more efficient memory-usage on very large results sets. (Note: at this time

@@ -159,3 +182,3 @@ the `sqlite3` driver does not support backpressure)

Internally, `Query` instances are
[created by a database Adapter][Adapter.createQuery] and may have more methods,
[created by a database Adapter][adapter.createquery] and may have more methods,
properties, and events than are described here. Consult the documentation for

@@ -167,3 +190,3 @@ your specific adapter to find out about any extensions.

The SQL query as a string. If you are using MySQL this will contain
interpolated values *after* the query has been enqueued by a connection.
interpolated values _after_ the query has been enqueued by a connection.

@@ -176,5 +199,5 @@ ### Query.values

The callback (if any) that was provided to [Queryable.query][Queryable.query].
The callback (if any) that was provided to [Queryable.query][queryable.query].
Note that `Query` objects **must not** use a closed over reference to their
callback, as other `any-db` libraries *may* rely on modifying the `callback`
callback, as other `any-db` libraries _may_ rely on modifying the `callback`
property of a `Query` they did not create.

@@ -192,3 +215,3 @@

* `error` - the error object.
- `error` - the error object.

@@ -201,3 +224,3 @@ #### Fields event

* `fields` - an array of [Field][ResultSet] objects.
- `fields` - an array of [Field][resultset] objects.

@@ -214,3 +237,3 @@ ### [Readable][] events

* `row` contains the contents of a single row in the query result
- `row` contains the contents of a single row in the query result

@@ -233,6 +256,6 @@ #### Close event

ResultSet := {
fields: Array<Field>
rows: Array<Object<Any>>
rowCount: Integer
lastInsertId: Any?
fields: Array<Field>
rows: Array<Object<Any>>
rowCount: Integer
lastInsertId?: Any
}

@@ -246,3 +269,3 @@

`ResultSet` objects are just plain data that collect results of a query when a
`ResultSet` objects are just plain data that collect results of a query when a
continuation is provided to [Queryable.query][]. The `lastInsertId` is optional,

@@ -258,3 +281,3 @@ and currently supported by `sqlite3` and `mysql` but not `postgres`, because

createConnection: (Object, Continuation<Connection>?) => Connection,
createQuery: (String, Array?, Continuation<Results>?) => Query,
createQuery: (String, Array?, Continuation<ResultSet>?) => Query,
}

@@ -285,7 +308,7 @@ ```

```ocaml
(text: String, params: Array?, Continuation<ResultSet>?) => Query
(text: String, params?: Array, Continuation<ResultSet>?) => Query
(Query) => Query {* returns same Query *}
```
Create a [Query](#query) that *may* eventually be executed later on by a
Create a [Query](#query) that _may_ eventually be executed later on by a
[Connection][]. While this function is rarely needed by user code, it makes

@@ -306,21 +329,18 @@ it possible for [ConnectionPool.query][] and [Transaction.query][] to fulfill

[any-db-sqlite3]: https://github.com/grncdr/node-any-db-sqlite3
[createConnection]: https://github.com/grncdr/node-any-db#exportscreateconnection
[Readable]: http://nodejs.org/api/stream.html#stream_class_stream_readable
[Readable.pipe]: http://nodejs.org/api/stream.html#stream_readable_pipe_destination_options
[ConnectionPool.query]: https://github.com/grncdr/node-any-db-pool#connectionpoolquery
[ConnectionPool.acquire]: https://github.com/grncdr/node-any-db-pool#connectionpoolacquire
[ConnectionPool]: https://github.com/grncdr/node-any-db-pool#api
[Transaction]: https://github.com/grncdr/node-any-db-transaction#api
[createconnection]: https://github.com/grncdr/node-any-db#exportscreateconnection
[readable]: http://nodejs.org/api/stream.html#stream_class_stream_readable
[readable.pipe]: http://nodejs.org/api/stream.html#stream_readable_pipe_destination_options
[connectionpool.query]: https://github.com/grncdr/node-any-db-pool#connectionpoolquery
[connectionpool.acquire]: https://github.com/grncdr/node-any-db-pool#connectionpoolacquire
[connectionpool]: https://github.com/grncdr/node-any-db-pool#api
[transaction]: https://github.com/grncdr/node-any-db-transaction#api
[any-db-transaction]: https://github.com/grncdr/node-any-db-transaction
[Transaction.query]: https://github.com/grncdr/node-any-db-transaction#transactionquery
[transaction.query]: https://github.com/grncdr/node-any-db-transaction#transactionquery
[test suite]: tests
[Adapter]: #adapter
[Queryable]: #queryable
[Queryable.query]: #queryablequery
[Connection]: #connection
[Connection.query]: #connectionquery
[Query]: #query
[Adapter.createQuery]: #adaptercreatequery
[adapter]: #adapter
[queryable]: #queryable
[queryable.query]: #queryablequery
[connection]: #connection
[connection.query]: #connectionquery
[query]: #query
[adapter.createquery]: #adaptercreatequery

@@ -8,8 +8,8 @@ var path = require('path')

module.exports = function runTests () {
module.exports = function runTests() {
var config = require('./config')
requireAll({
dirname: __dirname + '/tests',
filter: config.filter ? RegExp(config.filter) : undefined
filter: config.filter ? RegExp(config.filter) : undefined,
})
}
var tape = require('tape')
module.exports = function test (description, opts, callback) {
module.exports = function test(description, opts, callback) {
if (!callback) {

@@ -8,5 +8,5 @@ callback = opts

}
tape(description, function (t) {
tape(description, function(t) {
var config = require('./config')
config.adapter.createConnection(config.url, function (err, conn) {
config.adapter.createConnection(config.url, function(err, conn) {
if (err) throw err

@@ -13,0 +13,0 @@ if (opts.autoEnd !== false) t.on('end', conn.end.bind(conn))

@@ -1,24 +0,26 @@

require('../test')("Last insert id", function (conn, t) {
require('../test')('Last insert id', function(conn, t) {
if (conn.adapter.name == 'postgres') {
t.skip("Last insert ID not supported by postgres")
t.skip('Last insert ID not supported by postgres')
return t.end()
}
if (conn.adapter.name == 'mssql') {
t.skip('Last insert ID not supported by mssql')
return t.end()
}
t.plan(2)
conn.query("DROP TABLE last_insert_id_test", function (err) {})
conn.query('DROP TABLE last_insert_id_test', function(err) {})
if (conn.adapter.name == 'sqlite3') {
conn.query("CREATE TABLE last_insert_id_test (id integer primary key autoincrement, a int)")
conn.query('CREATE TABLE last_insert_id_test (id integer primary key autoincrement, a int)')
} else if (conn.adapter.name == 'mysql') {
conn.query('CREATE TABLE last_insert_id_test (id integer primary key auto_increment, a int)')
} else {
throw new Error('Unknown adapter: ' + conn.adapter.name)
}
else if (conn.adapter.name == 'mysql') {
conn.query("CREATE TABLE last_insert_id_test (id integer primary key auto_increment, a int)")
}
else {
throw new Error("Unknown adapter: " + conn.adapter.name)
}
conn.query('INSERT INTO last_insert_id_test (a) VALUES (123)', function (err, res) {
conn.query('INSERT INTO last_insert_id_test (a) VALUES (123)', function(err, res) {
if (err) throw err
t.equal(res.lastInsertId, 1)
conn.query('INSERT INTO last_insert_id_test (a) VALUES (456)', function (err, res) {
conn.query('INSERT INTO last_insert_id_test (a) VALUES (456)', function(err, res) {
if (err) throw err

@@ -25,0 +27,0 @@ t.equal(res.lastInsertId, 2)

@@ -1,16 +0,19 @@

require('../test')("Modification counts", function (conn, t) {
t.plan(2)
require('../test')('Modification counts', function(conn, t) {
t.plan(3)
conn.query("DROP TABLE modification_count_test", function (err) {})
conn.query("CREATE TABLE modification_count_test (a int)")
conn.query('DROP TABLE modification_count_test', function(err) {})
conn.query('CREATE TABLE modification_count_test (a int)')
conn.query('INSERT INTO modification_count_test (a) VALUES (123)', function (err, res) {
conn.query('INSERT INTO modification_count_test (a) VALUES (123)', function(err, res) {
if (err) throw err
t.equal(res.rowCount, 1, 'INSERT query result has correct rowCount')
conn.query('UPDATE modification_count_test SET a = 3', function (err, res) {
conn.query('UPDATE modification_count_test SET a = 3', function(err, res) {
if (err) throw err
t.equal(res.rowCount, 1, 'UPDATE query result has correct rowCount')
conn.query('DROP TABLE modification_count_test', function(err) {
t.error(err)
})
})
})
})

@@ -1,11 +0,11 @@

require('../test')('Query errors', function (conn, t) {
require('../test')('Query errors', function(conn, t) {
t.plan(2)
conn.query('invalid sql statement', function (err) {
conn.query('invalid sql statement', function(err) {
t.ok(err, 'received error in callback')
})
conn.query('invalid sql statement').on('error', function (err) {
conn.query('invalid sql statement').on('error', function(err) {
t.ok(err, 'received error in error event')
})
})

@@ -1,4 +0,4 @@

require('../test')("Query events", function (conn, t) {
conn.query("DROP TABLE IF EXISTS streaming_test")
conn.query("CREATE TABLE streaming_test (a int)")
require('../test')('Query events', function(conn, t) {
conn.query('DROP TABLE IF EXISTS streaming_test')
conn.query('CREATE TABLE streaming_test (a int)')

@@ -9,35 +9,45 @@ // prepare our data

conn.query('INSERT INTO streaming_test (a) VALUES (' + i + ')')
expected.push({a: i})
expected.push({ a: i })
}
t.test('events with a callback', function (t) {
var fields, gotEnd;
t.test('events with a callback', function(t) {
var fields, gotEnd
t.plan(4)
conn.query('SELECT a FROM streaming_test', function (err, result) {
t.deepEqual(result.fields, fields, "got same fields in result")
t.deepEqual(result.rows, expected, "got expected rows")
}).on('fields', function (_fields) {
t.pass('got "fields" event')
fields = _fields
}).on('end', function () {
t.pass('got "end" event')
})
conn
.query('SELECT a FROM streaming_test', function(err, result) {
t.deepEqual(result.fields, fields, 'got same fields in result')
t.deepEqual(result.rows, expected, 'got expected rows')
})
.on('fields', function(_fields) {
t.pass('got "fields" event')
fields = _fields
})
.on('end', function() {
t.pass('got "end" event')
})
})
t.test('events with no callback (stream)', function (t) {
t.test('events with no callback (stream)', function(t) {
var received = []
var fields;
var fields
t.plan(2)
conn.query('SELECT a FROM streaming_test')
.on('fields', function (_fields) {
conn
.query('SELECT a FROM streaming_test')
.on('fields', function(_fields) {
fields = _fields
})
.on('data', function (row) {
.on('data', function(row) {
received.push(row)
})
.on('end', function () {
t.ok(fields, "got fields event")
.on('end', function() {
t.ok(fields, 'got fields event')
t.deepEqual(expected, received)
})
})
t.test('cleanup', function(t) {
conn.query('DROP TABLE streaming_test', function() {
t.end()
})
})
})

@@ -5,6 +5,6 @@ var test = require('tape')

var config = require('../config')
var config = require('../config')
var adapter = config.adapter
test('Connection & Query events', function (t) {
test('Connection & Query events', function(t) {
t.plan(interfaces.Connection.testEvents.plan)

@@ -11,0 +11,0 @@ var connection = adapter.createConnection(config.url)

@@ -5,7 +5,6 @@ var test = require('tape')

var config = require('../config')
var config = require('../config')
var adapter = config.adapter
test("Adapter properties", function (t) {
test('Adapter properties', function(t) {
interfaces.Adapter.testProperties(adapter, t)

@@ -15,4 +14,4 @@ t.end()

test('Connection properties', function (t) {
t.test('sync connection creation', function (t) {
test('Connection properties', function(t) {
t.test('sync connection creation', function(t) {
var conn = adapter.createConnection(config.url)

@@ -24,4 +23,4 @@ interfaces.Connection.testProperties(conn, adapter, t)

t.test('async connection creation', function (t) {
adapter.createConnection(config.url, function (err, conn) {
t.test('async connection creation', function(t) {
adapter.createConnection(config.url, function(err, conn) {
interfaces.Connection.testProperties(conn, adapter, t)

@@ -34,3 +33,3 @@ conn.end()

test('Query properties', function (t) {
test('Query properties', function(t) {
var sql = 'SELECT 1 AS ok WHERE 1 = $1'

@@ -46,3 +45,3 @@ var query = adapter.createQuery(sql, [1], queryCallback)

function queryCallback (err, res) {
function queryCallback(err, res) {
/** an empty callback we're just using for an identity check */

@@ -52,9 +51,9 @@ }

test('ResultSet properties', function (t) {
test('ResultSet properties', function(t) {
var conn = adapter.createConnection(config.url)
conn.query('SELECT 10 AS "shouldBeTen"', function (err, result) {
if (err) throw err;
conn.query('SELECT 10 AS "shouldBeTen"', function(err, result) {
if (err) throw err
interfaces.ResultSet.testProperties(result, t)
t.equal(result.fields[0].name, "shouldBeTen", "field has a name property")
t.equal(result.fields[0].name, 'shouldBeTen', 'field has a name property')
t.equal(result.rowCount, 1, 'rowCount == 1')

@@ -61,0 +60,0 @@ t.equal(result.rows[0].shouldBeTen, 10, 'shouldBeTen == 10')

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc