Comments (4)
Please paste the simplest possible code that makes the error.
from node-firebird-drivers.
Hello,
I made an example like follows:
CREATE TABLE TESTDATE (
ID SMALLINT GENERATED BY DEFAULT AS IDENTITY (START WITH 1) NOT NULL,
SOME_DATE DATE);
CREATE OR ALTER PROCEDURE TESTDATE1(
XSOMEDATE DATE)
RETURNS(
ID SMALLINT
)
AS
BEGIN
INSERT INTO TESTDATE(SOME_DATE)
VALUES (:XSOMEDATE) RETURNING ID
INTO :ID;
SUSPEND;
END
The procedure in nodejs:
const createNativeClient = require('node-firebird-driver-native').createNativeClient;
const getDefaultLibraryFilename = require('node-firebird-driver-native').getDefaultLibraryFilename;
const config = require(__configDir).configGol
async function testQuery(query, params =[]) {
const dbase = 'ASD' //path to config..
const client = createNativeClient(getDefaultLibraryFilename())
const theDb = config(dbase).database
const theUser = config(dbase).user
const thePass = config(dbase).password
const attachment = await client.connect(theDb, {
password: thePass,
username: theUser
}).catch((e) => console.log(e))
if (!_.size(attachment)) {
console.log('DATABASE CONNECTION ', `${chalk.keyword('yellow')(`${dbase}`)}: ${chalk.bgRed(' FAILED 1110')}`);
return []
}
const transaction = await attachment.startTransaction();
try{
const resultSet = await attachment.executeQuery(transaction, query, params)
const rows = await resultSet.fetchAsObject()
await resultSet.close();
await transaction.commit();
await client.dispose();
return rows;
} catch (err){
await transaction.rollback();
await client.dispose();
return Object.assign({}, {ERROR:err, dbase: dbase, query: query, params: params, FLAG: 1043});
}
}
Then if I run this :
setTimeout( async() => {
let row = await testQuery(`SELECT ID FROM TESTDATE1(?);`, ['1/1/1989'])
console.log('row', row)
}, 1000);
I get error:
row {
ERROR: TypeError: date.getFullYear is not a function
at Object.<anonymous> (/var/lib/sws/engine/svsync/node_modules/node-firebird-driver/dist/lib/impl/fb-util.js:289:86)
at Generator.next (<anonymous>)
at /var/lib/sws/engine/svsync/node_modules/node-firebird-driver/dist/lib/impl/fb-util.js:8:71
at new WrappedPromise (/var/lib/sws/engine/svsync/node_modules/async-listener/es6-wrapped-promise.js:13:18)
at __awaiter (/var/lib/sws/engine/svsync/node_modules/node-firebird-driver/dist/lib/impl/fb-util.js:4:12)
at mappers.<computed> (/var/lib/sws/engine/svsync/node_modules/node-firebird-driver/dist/lib/impl/fb-util.js:241:66)
at /var/lib/sws/engine/svsync/node_modules/node-firebird-driver/dist/lib/impl/fb-util.js:338:58
at Array.map (<anonymous>)
at Object.<anonymous> (/var/lib/sws/engine/svsync/node_modules/node-firebird-driver/dist/lib/impl/fb-util.js:338:35)
at Generator.next (<anonymous>),
dbase: 'ASD',
query: 'SELECT ID FROM TESTDATE1(?);',
params: [ '1/1/1989' ],
FLAG: 1043
}
But if I run like this:
setTimeout( async() => {
let row = await testQuery(`SELECT ID FROM TESTDATE1('1/1/1989');`, [])
console.log('row', row)
}, 1000);
There is no error and returns correctly
row [ { ID: 15 } ]
Thank you!!!
from node-firebird-drivers.
The builtin tests uses a Date
object. What's the error using Date
?
from node-firebird-drivers.
I find out now that this works correctly here!
await testQuery(`SELECT ID FROM TESTDATE1(?);`, [new Date('1/1/1989')])
In the real situation the params are comming long way, so the situation is more like:
await testQuery(`SELECT ID FROM TESTDATE1(?);`, [JSON.parse(JSON.stringify(new Date('1/1/1989')))])
which errors:
row {
ERROR: TypeError: date.getFullYear is not a function
at Object.<anonymous> (/var/lib/sws/engine/svsync/node_modules/node-firebird-driver/dist/lib/impl/fb-util.js:289:86)
at Generator.next (<anonymous>)
at /var/lib/sws/engine/svsync/node_modules/node-firebird-driver/dist/lib/impl/fb-util.js:8:71
at new WrappedPromise (/var/lib/sws/engine/svsync/node_modules/async-listener/es6-wrapped-promise.js:13:18)
at __awaiter (/var/lib/sws/engine/svsync/node_modules/node-firebird-driver/dist/lib/impl/fb-util.js:4:12)
at mappers.<computed> (/var/lib/sws/engine/svsync/node_modules/node-firebird-driver/dist/lib/impl/fb-util.js:241:66)
at /var/lib/sws/engine/svsync/node_modules/node-firebird-driver/dist/lib/impl/fb-util.js:338:58
at Array.map (<anonymous>)
at Object.<anonymous> (/var/lib/sws/engine/svsync/node_modules/node-firebird-driver/dist/lib/impl/fb-util.js:338:35)
at Generator.next (<anonymous>),
dbase: 'ASD',
query: 'SELECT ID FROM TESTDATE1(?);',
params: [ '1988-12-31T22:00:00.000Z' ],
FLAG: 1043
}
from node-firebird-drivers.
Related Issues (20)
- Add property Statement.hasResultSet
- Add method Statement.setCursorName
- How to determine either transaction active or not? HOT 7
- Add support for Visual Studio 2022 build HOT 5
- Add method Statement.getExecPathText
- how to get EXPLAIN PLAN of select HOT 1
- Deprecate methods executeReturning* replacing by executeSingleton*
- Hi Pooling HOT 2
- Add options to Attachment.createBlob for stream blob creation
- Add method BlobStream.seek
- Update target code to ES2020 (node.js 14 compatible)
- macOS failing example HOT 2
- bug: unhandled exception - executeQuery HOT 9
- BUG, all dates are behind 1 day on UTC+nn timezones (eastern region)
- Error while building: ModuleNotFoundError: No module named 'distutils'
- Reaching out
- "wrong ELF class: ELFCLASS64" on a RaspberryPi 3b
- Doesn't compile with latest Nodejs 21.7.3 HOT 1
- Blob as string
- Support for text BLOBs and character set transliteration
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-firebird-drivers.