Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: date.getFullYear is not a function (again) #158

Open
mariocarro opened this issue Feb 6, 2025 · 2 comments
Open

TypeError: date.getFullYear is not a function (again) #158

mariocarro opened this issue Feb 6, 2025 · 2 comments

Comments

@mariocarro
Copy link

mariocarro commented Feb 6, 2025

This should be a continuation of issue #90, but I cannot reopen that issue.

I'm facing the same problem, but reach a different conclusion: Shouldn't node-firebird-driver try to handle the case where the timestamp value (in my case, would be date value in the code posted in issue #90) is a string?

It's not difficult, in the function createDataWriter in fb-util.ts of node-firebird-driver, in the sqlTypes.SQL_TIMESTAMP case (and others), one could do this:
const date = typeof(value) === 'string' ? new Date(value) : value as Date;
instead of blindly doing this:
const date = value as Date;
and that solves de problem.

Rationale: Providing string values to timestamp parameters is very common and widely supported by other databases. In this case I'm building a backend app publishing different service endpoints using feathers.js with knex-firebird-dialect (that depends on node-firebird-drivers). This same use case that fails using node-firebird-drivers to handle database connections, is processed without issues when the database is (for example) postgresql, mssql or sqlite.

The transformation of the parameter values from string to Date cannot be made higher up in call chain because outside of the driver there is no knowledge of the actual data types of the database columns, so no way to know that the change should be made (other than in the application code, but would be very cumbersome and, as I said, not needed with other databases).

@asfernandes
Copy link
Owner

Can you submit PR?

@luiz-limber
Copy link

na realidade acredito que se passado um parâmetro Data / Hora etc. como string ele deveria ser enviado como string para o Firebird.

já que a conversão é suportada pelo banco de dados.

caso seja criada um new Date(value) pode ocorrer problemas ao enviar formatos de data que são diferentes entre o FB e o Javascript.

Ex:

'31.01.2001' => FB 31/01/2001
new Date('31.01.2001') => Javascript Invalid Date

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants