Feature Request: Handling JS Date variables
まだ誰も着手していません。
- 主要言語
- JavaScript
- スター
- 13.7k
- フォーク
- 1.1k
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
First of all, thanks for creating/maintaining this amazing library. I'll cut into my request.
Background
I am using sql.js with typeorm to do integration testing rather than spinning up a mysql service for that.
Issue
I noted that if I use Javascript Date objects in the where conditions, it works in production, but fails in tests, because sql.js doesn't convert the dates similar to how node-mysql driver does that.
Expectation
I would love it if sql.js would convert the dates correctly.
For example, take the following example:
const updatedAt = new Date(/*Some date string goes here*/);
// Assume db is setup correctly as explained in ReadMe
db.run("SELECT * FROM test_table WHERE example_column = ?", [updatedAt]);
Now, this fails because sql.js would call updatedAt.toString(). But AFAIK, in node-mysql they call updatedAt.toISOString() (or some valid date string) internally.
Notes
- Code works with sql.js when we do
updatedAt.toISOString()explicitly - The error that's being thrown at the moment is:
QueryFailedError: Wrong API use : tried to bind a value of an unknown type (Fri Jan 11 2019 01:01:01 GMT+1100 (Australian Eastern Daylight Time)).
at new QueryFailedError (/Users/pubudu/Projects/typeorm-test/src/error/QueryFailedError.ts:9:9)
at SqljsQueryRunner.<anonymous> (/Users/pubudu/Projects/typeorm-test/src/driver/sqljs/SqljsQueryRunner.ts:79:22)
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
Start by reproducing the db.run example with a JavaScript Date value and inspect the parameter-binding path that produces the reported unknown-type error. The issue mentions SqljsQueryRunner.ts:79:22 in the stack trace; done means Date parameters are accepted with the expected SQL date representation and the existing binding behavior remains covered by a test.
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript, sqlite
- 領域
- databases
- issue の種類
- 機能追加
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 45/100