@mikro-orm/sql 7.2.9-dev.14 → 7.2.9-dev.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -63,7 +63,11 @@ export declare abstract class AbstractSqlDriver<Connection extends AbstractSqlCo
63
63
  private nativeCloneTPT;
64
64
  private mapCloneOverrides;
65
65
  private buildCloneFields;
66
- private getCloneableProps;
66
+ /**
67
+ * Returns properties whose columns can be copied by an `INSERT … SELECT` (owning columns that are not PKs, generated or formulas).
68
+ * @internal
69
+ */
70
+ getCloneableProps<T extends object>(meta: EntityMetadata<T>, ownProps?: boolean): EntityProperty<T>[];
67
71
  nativeInsertMany<T extends object>(entityName: EntityName<T>, data: EntityDictionary<T>[], options?: NativeInsertUpdateManyOptions<T>, transform?: (sql: string) => string): Promise<QueryResult<T>>;
68
72
  /** Resolves the primary key of every inserted row from the supplied data or the returned rows, and reports them via `insertedIds` when all are known. */
69
73
  protected resolveInsertedPrimaryKeys<T extends object>(meta: EntityMetadata<T>, data: EntityDictionary<T>[], res: QueryResult<T>): any[][];
@@ -763,25 +763,12 @@ export class AbstractSqlDriver extends DatabaseDriver {
763
763
  }
764
764
  return { selectFields, insertColumns };
765
765
  }
766
+ /**
767
+ * Returns properties whose columns can be copied by an `INSERT … SELECT` (owning columns that are not PKs, generated or formulas).
768
+ * @internal
769
+ */
766
770
  getCloneableProps(meta, ownProps) {
767
- return (ownProps ? (meta.ownProps ?? meta.props) : meta.props).filter(prop => {
768
- if (prop.persist === false) {
769
- return false;
770
- }
771
- if (prop.primary) {
772
- return false;
773
- }
774
- if (!prop.fieldNames?.length) {
775
- return false;
776
- }
777
- if ([ReferenceKind.ONE_TO_MANY, ReferenceKind.MANY_TO_MANY].includes(prop.kind)) {
778
- return false;
779
- }
780
- if (prop.kind === ReferenceKind.EMBEDDED && !prop.object) {
781
- return false;
782
- }
783
- return true;
784
- });
771
+ return (ownProps ? (meta.ownProps ?? meta.props) : meta.props).filter(prop => !prop.primary && !prop.generated && this.platform.shouldHaveColumn(prop, true, undefined, false, false));
785
772
  }
786
773
  async nativeInsertMany(entityName, data, options = {}, transform) {
787
774
  options.processCollections ??= true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/sql",
3
- "version": "7.2.9-dev.14",
3
+ "version": "7.2.9-dev.15",
4
4
  "description": "TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.",
5
5
  "keywords": [
6
6
  "data-mapper",
@@ -53,7 +53,7 @@
53
53
  "@mikro-orm/core": "^7.2.8"
54
54
  },
55
55
  "peerDependencies": {
56
- "@mikro-orm/core": "7.2.9-dev.14"
56
+ "@mikro-orm/core": "7.2.9-dev.15"
57
57
  },
58
58
  "engines": {
59
59
  "node": ">= 22.17.0"
@@ -980,8 +980,6 @@ export declare class QueryBuilder<Entity extends object = AnyEntity, RootAlias e
980
980
  * Tier 3: Derive from target entity metadata (all cloneable columns), auto-populate source select
981
981
  */
982
982
  private resolveInsertFromColumns;
983
- /** Returns properties that are safe to clone (persistable, non-PK, non-generated). */
984
- private getCloneableProps;
985
983
  private applyDiscriminatorCondition;
986
984
  /**
987
985
  * Ensures TPT joins are applied. Can be called early before finalize() to populate
@@ -1884,7 +1884,7 @@ export class QueryBuilder {
1884
1884
  });
1885
1885
  }
1886
1886
  // Tier 3: derive from metadata — all cloneable columns
1887
- const cloneableProps = this.getCloneableProps(meta);
1887
+ const cloneableProps = this.driver.getCloneableProps(meta);
1888
1888
  const selectFields = [];
1889
1889
  const columns = [];
1890
1890
  for (const prop of cloneableProps) {
@@ -1899,27 +1899,6 @@ export class QueryBuilder {
1899
1899
  }
1900
1900
  return columns;
1901
1901
  }
1902
- /** Returns properties that are safe to clone (persistable, non-PK, non-generated). */
1903
- getCloneableProps(meta) {
1904
- return meta.props.filter(prop => {
1905
- if (prop.persist === false) {
1906
- return false;
1907
- }
1908
- if (prop.primary) {
1909
- return false;
1910
- }
1911
- if (!prop.fieldNames?.length) {
1912
- return false;
1913
- }
1914
- if ([ReferenceKind.ONE_TO_MANY, ReferenceKind.MANY_TO_MANY].includes(prop.kind)) {
1915
- return false;
1916
- }
1917
- if (prop.kind === ReferenceKind.EMBEDDED && !prop.object) {
1918
- return false;
1919
- }
1920
- return true;
1921
- });
1922
- }
1923
1902
  applyDiscriminatorCondition() {
1924
1903
  const meta = this.mainAlias.meta;
1925
1904
  if (meta.root.inheritanceType !== 'sti' || !meta.discriminatorValue) {