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

Array of embeddable with date property always updated #4360

Closed
vinverdy opened this issue May 16, 2023 · 2 comments
Closed

Array of embeddable with date property always updated #4360

vinverdy opened this issue May 16, 2023 · 2 comments

Comments

@vinverdy
Copy link
Contributor

vinverdy commented May 16, 2023

Describe the bug
always updated the row, maybe related with #4078

/* istanbul ignore file */
/* eslint-disable */
import { Embeddable, Embedded, Entity, PrimaryKey, Property } from '@mikro-orm/core';
import { MikroORM } from '@mikro-orm/postgresql';

@Embeddable()
export abstract class Animal {
  @Property()
  public readonly birthday!: Date;
}

@Entity()
export class Owner {
  @PrimaryKey()
  id!: number;

  @Embedded(() => Animal, { array: true })
  pet!: Animal[];
}

let orm: MikroORM;

beforeAll(async () => {
  orm = await MikroORM.init({
    entities: [Owner],
    debug: true,
    allowGlobalContext: true,
  });

  await orm.schema.refreshDatabase();
});

afterAll(async () => {
  await orm.close(true);
});

it('doing some update when shouldnt', async () => {
  await orm.em.insert(Owner, {
    id: 1,
    pet: [
      {
        birthday: new Date(),
      },
    ],
  });
  await orm.em.findOneOrFail(Owner, 1);
  await orm.em.flush();
});

image

@B4nan
Copy link
Member

B4nan commented May 19, 2023

The solution to this will be the same as for #4362, which is enforcing the conversion via the custom type instead of relying on the driver. Will close this as a duplicate, please subscribe there.

As a workaround, you can specify the custom type explicitly:

@Property({ type: DateTimeType })
birthday!: Date;

@B4nan B4nan closed this as not planned Won't fix, can't repro, duplicate, stale May 19, 2023
@B4nan
Copy link
Member

B4nan commented May 26, 2023

This was actually a bit different issue that I originally though, but it will be also resolved by #4391.

@B4nan B4nan closed this as completed May 26, 2023
B4nan added a commit that referenced this issue May 27, 2023
Previously, mapping of datetime columns to JS `Date` objects was
dependent on the driver, while SQLite didn't have this out of box
support and required manual conversion on various places. There were
also places that didn't convert dates properly, e.g. inside embedded
objects. All drivers now have disabled `Date` conversion and this is
handled explicitly, in the same way for all the drivers.

Moreover, the `date` type was previously seen as a `datetime`, while now
only `Date` (with uppercase `D`) will be considered as `datetime`, while
`date` is just a `date`.

Closes #4362
Closes #4360
Closes #1476
B4nan added a commit that referenced this issue Jun 11, 2023
Previously, mapping of datetime columns to JS `Date` objects was
dependent on the driver, while SQLite didn't have this out of box
support and required manual conversion on various places. There were
also places that didn't convert dates properly, e.g. inside embedded
objects. All drivers now have disabled `Date` conversion and this is
handled explicitly, in the same way for all the drivers.

Moreover, the `date` type was previously seen as a `datetime`, while now
only `Date` (with uppercase `D`) will be considered as `datetime`, while
`date` is just a `date`.

Closes #4362
Closes #4360
Closes #1476
B4nan added a commit that referenced this issue Sep 10, 2023
Previously, mapping of datetime columns to JS `Date` objects was
dependent on the driver, while SQLite didn't have this out of box
support and required manual conversion on various places. There were
also places that didn't convert dates properly, e.g. inside embedded
objects. All drivers now have disabled `Date` conversion and this is
handled explicitly, in the same way for all the drivers.

Moreover, the `date` type was previously seen as a `datetime`, while now
only `Date` (with uppercase `D`) will be considered as `datetime`, while
`date` is just a `date`.

Closes #4362
Closes #4360
Closes #1476
B4nan added a commit that referenced this issue Sep 20, 2023
Previously, mapping of datetime columns to JS `Date` objects was
dependent on the driver, while SQLite didn't have this out of box
support and required manual conversion on various places. There were
also places that didn't convert dates properly, e.g. inside embedded
objects. All drivers now have disabled `Date` conversion and this is
handled explicitly, in the same way for all the drivers.

Moreover, the `date` type was previously seen as a `datetime`, while now
only `Date` (with uppercase `D`) will be considered as `datetime`, while
`date` is just a `date`.

Closes #4362
Closes #4360
Closes #1476
B4nan added a commit that referenced this issue Sep 24, 2023
Previously, mapping of datetime columns to JS `Date` objects was
dependent on the driver, while SQLite didn't have this out of box
support and required manual conversion on various places. There were
also places that didn't convert dates properly, e.g. inside embedded
objects. All drivers now have disabled `Date` conversion and this is
handled explicitly, in the same way for all the drivers.

Moreover, the `date` type was previously seen as a `datetime`, while now
only `Date` (with uppercase `D`) will be considered as `datetime`, while
`date` is just a `date`.

Closes #4362
Closes #4360
Closes #1476
B4nan added a commit that referenced this issue Sep 30, 2023
Previously, mapping of datetime columns to JS `Date` objects was
dependent on the driver, while SQLite didn't have this out of box
support and required manual conversion on various places. There were
also places that didn't convert dates properly, e.g. inside embedded
objects. All drivers now have disabled `Date` conversion and this is
handled explicitly, in the same way for all the drivers.

Moreover, the `date` type was previously seen as a `datetime`, while now
only `Date` (with uppercase `D`) will be considered as `datetime`, while
`date` is just a `date`.

Closes #4362
Closes #4360
Closes #1476
B4nan added a commit that referenced this issue Oct 2, 2023
Previously, mapping of datetime columns to JS `Date` objects was
dependent on the driver, while SQLite didn't have this out of box
support and required manual conversion on various places. There were
also places that didn't convert dates properly, e.g. inside embedded
objects. All drivers now have disabled `Date` conversion and this is
handled explicitly, in the same way for all the drivers.

Moreover, the `date` type was previously seen as a `datetime`, while now
only `Date` (with uppercase `D`) will be considered as `datetime`, while
`date` is just a `date`.

Closes #4362
Closes #4360
Closes #1476
B4nan added a commit that referenced this issue Oct 17, 2023
Previously, mapping of datetime columns to JS `Date` objects was
dependent on the driver, while SQLite didn't have this out of box
support and required manual conversion on various places. There were
also places that didn't convert dates properly, e.g. inside embedded
objects. All drivers now have disabled `Date` conversion and this is
handled explicitly, in the same way for all the drivers.

Moreover, the `date` type was previously seen as a `datetime`, while now
only `Date` (with uppercase `D`) will be considered as `datetime`, while
`date` is just a `date`.

Closes #4362
Closes #4360
Closes #1476
B4nan added a commit that referenced this issue Oct 21, 2023
Previously, mapping of datetime columns to JS `Date` objects was
dependent on the driver, while SQLite didn't have this out of box
support and required manual conversion on various places. There were
also places that didn't convert dates properly, e.g. inside embedded
objects. All drivers now have disabled `Date` conversion and this is
handled explicitly, in the same way for all the drivers.

Moreover, the `date` type was previously seen as a `datetime`, while now
only `Date` (with uppercase `D`) will be considered as `datetime`, while
`date` is just a `date`.

Closes #4362
Closes #4360
Closes #1476
B4nan added a commit that referenced this issue Oct 25, 2023
Previously, mapping of datetime columns to JS `Date` objects was
dependent on the driver, while SQLite didn't have this out of box
support and required manual conversion on various places. There were
also places that didn't convert dates properly, e.g. inside embedded
objects. All drivers now have disabled `Date` conversion and this is
handled explicitly, in the same way for all the drivers.

Moreover, the `date` type was previously seen as a `datetime`, while now
only `Date` (with uppercase `D`) will be considered as `datetime`, while
`date` is just a `date`.

Closes #4362
Closes #4360
Closes #1476
B4nan added a commit that referenced this issue Nov 2, 2023
Previously, mapping of datetime columns to JS `Date` objects was
dependent on the driver, while SQLite didn't have this out of box
support and required manual conversion on various places. There were
also places that didn't convert dates properly, e.g. inside embedded
objects. All drivers now have disabled `Date` conversion and this is
handled explicitly, in the same way for all the drivers.

Moreover, the `date` type was previously seen as a `datetime`, while now
only `Date` (with uppercase `D`) will be considered as `datetime`, while
`date` is just a `date`.

Closes #4362
Closes #4360
Closes #1476
B4nan added a commit that referenced this issue Nov 5, 2023
Previously, mapping of datetime columns to JS `Date` objects was
dependent on the driver, while SQLite didn't have this out of box
support and required manual conversion on various places. There were
also places that didn't convert dates properly, e.g. inside embedded
objects. All drivers now have disabled `Date` conversion and this is
handled explicitly, in the same way for all the drivers.

Moreover, the `date` type was previously seen as a `datetime`, while now
only `Date` (with uppercase `D`) will be considered as `datetime`, while
`date` is just a `date`.

Closes #4362
Closes #4360
Closes #1476
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

2 participants