Repository navigation
feat: time with timezone - #14213
feat: time with timezone#14213oleksandr-petryk wants to merge 16 commits into
Conversation
|
I did have similar error when test the code locally. But it was with Can I fix this or can I just wait? |
|
Don't worry about the failing DB2 tests, they are not related to your PR |
ephys
left a comment
There was a problem hiding this comment.
Thank you for the PR :)
A few copy-paste errors, and one potentially failing scenario, but overall looking good
Could you also add DataTypes.TIME.ZONED in the documentation? https://github.com/sequelize/sequelize/blob/main/docs/manual/other-topics/other-data-types.md
|
Okay I add documentation |
|
I forgot one last test: the integration one It tests that the value you put in is properly serialized/deserialized when sent/retrieved from the database. It goes in sequelize/test/integration/data-types.test.js Line 162 in 85b0984 The test must only be enabled for dialects that support
I'd recommend naming the flag This may be a lot in one go but I'm pretty sure it's the last thing :) |
|
If I need to update something, I do it. Thank you for patience :) |
|
I'm not sure why test integration test is failing (to be honest it's the first time I look into that test suite). I'll assign this to myself to remind myself to take a look into it when I'm available :) |
|
About when will the new version of Sequelize be released? |
|
The new v6 release that includes this? Not sure, I need to find the time to figure out how to write this test |
|
I'm just wondering when I will be able to use the data type. I created the data type locally so as not to stop the development of my project. So take your time :) |
I think we might need to rewrite the testSuccess function there. I don't think it can deal with the |
|
I tried to write the test, but I don't know how else to implement it. Oh, I got it, I'll try again |
|
I don't know if it's another error or if it caused an error before Error:1) [POSTGRES] DataTypes
calls parse and stringify for TIME WITH TIMEZONE:
invalid input syntax for type time with time zone: "{}"
Error
at Query.run (lib/dialects/postgres/query.js:55:25)
at /home/petryk/dev/sequelize/lib/sequelize.js:321:28
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async PostgresQueryInterface.insert (lib/dialects/abstract/query-interface.js:297:21)
at async model.save (lib/model.js:2442:35)
at async Function.create (lib/model.js:1348:12)
at async Context.<anonymous> (test/integration/data-types.test.js:199:7)Test: if (current.dialect.supports.TIME_WITH_TIME_ZONE) {
it('calls parse and stringify for TIME WITH TIMEZONE', async () => {
const Type = new Sequelize.TIME({ zoned: true });
const value = '12:00:00 +02:00';
const options = {};
let parseHaveBeenCalled = false;
let stringifyHaveBeenCalled = false;
// await testSuccess(Type, moment(new Date()).format('hh:mm:ss ZZ'));
Type.constructor.parse = value => {
parseHaveBeenCalled = true;
return value;
};
Type.constructor.prototype.stringify = () => {
stringifyHaveBeenCalled = true;
return Reflect.apply(Sequelize.ABSTRACT.prototype.stringify, this, arguments);
};
const User = current.define('user', {
field: Type,
}, {
timestamps: false,
});
await current.sync({ force: true });
current.refreshTypes();
await User.create({ // <<< error here
field: value,
});
await User.findAll();
expect(parseHaveBeenCalled).to.be.equal(true);
expect(stringifyHaveBeenCalled).to.be.equal(true);
delete Type.constructor.parse;
delete Type.constructor.prototype.stringify;
}); |
|
I just resolved the conflicts. If it's ok with @Sasha-hk I'll take over the branch to look into the test issue |
|
Okay |
|
Ok so the issue is that It's nowhere nearly as useful as testing that the value is correctly serialized/deserialized when interacting with the database. I'll rewrite the test suite in a follow-up PR, after #14373 has been merged. In the meantime, this PR doesn't do anything weird, so it has my approval |
|
Yep! That branch revamps the test suite completely |
|
I've done a lot more data type research in the past months with the data type rewrite and I think we should not include support for I'm sorry it comes after all this effort, but I propose to abandon this feature |
I agree with you, we can close this PR |
Pull Request Checklist
Please make sure to review and check all of these items:
yarn testoryarn test-DIALECTpass with this change (including linting)?Description Of Change
Closes #14211
Create data type to store only time with timezone