orchid-orm 1.63.0 → 1.63.2

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.
@@ -533,16 +533,17 @@ const compareColumns = async (config, adapter, domainsMap, ast, currentSchema, c
533
533
  compareSql.values.length = valuesBeforeLen;
534
534
  return "change";
535
535
  } else if (dbDefault !== codeDefault && dbDefault !== `(${codeDefault})`) {
536
+ const change = () => {
537
+ changeColumn(changeTableData, key, dbName, dbColumn, codeColumn);
538
+ if (!changeTableData.pushedAst) {
539
+ changeTableData.pushedAst = true;
540
+ ast.push(changeTableData.changeTableAst);
541
+ }
542
+ };
536
543
  compareSql.expressions.push({
537
544
  inDb: dbDefault,
538
545
  inCode: codeDefault,
539
- change: () => {
540
- changeColumn(changeTableData, key, dbName, dbColumn, codeColumn);
541
- if (!changeTableData.pushedAst) {
542
- changeTableData.pushedAst = true;
543
- ast.push(changeTableData.changeTableAst);
544
- }
545
- }
546
+ change
546
547
  });
547
548
  }
548
549
  }
@@ -2029,12 +2030,15 @@ const getColumnDbTypeForComparison = (column, currentSchema) => {
2029
2030
  return `"${type.slice(j)}"."${type.slice(0, j)}"${append}`;
2030
2031
  }
2031
2032
  };
2033
+ const freezeSqlClock = (sql) => sql.replaceAll("clock_timestamp()", "now()");
2032
2034
  const applyCompareSql = async (compareSql, adapter) => {
2033
2035
  if (compareSql.expressions.length) {
2034
2036
  const {
2035
2037
  rows: [results]
2036
2038
  } = await adapter.arrays(
2037
- "SELECT " + compareSql.expressions.map((x) => `${x.inDb} = (${x.inCode})`).join(", "),
2039
+ "SELECT " + compareSql.expressions.map(
2040
+ (x) => `${freezeSqlClock(x.inDb)} = (${x.inCode && freezeSqlClock(x.inCode)})`
2041
+ ).join(", "),
2038
2042
  compareSql.values
2039
2043
  );
2040
2044
  for (let i = 0; i < results.length; i++) {