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