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