diff --git a/src/server/sync.dto.ts b/src/server/sync.dto.ts index 468b24e..d2b2bbb 100644 --- a/src/server/sync.dto.ts +++ b/src/server/sync.dto.ts @@ -1,7 +1,15 @@ import { z } from "zod/v4"; export const SyncRequest = z.object({ - db: z.string().startsWith("postgres://"), + // We shouldn't be doing separate validations on both the front end and here? Should probably consolidate + db: z + .string() + .refine( + (val) => val.startsWith("postgres://") || val.startsWith("postgresql://"), + { + message: "Must start with 'postgres://' or 'postgresql://'", + } + ), seed: z.coerce.number().min(0).max(1).default(0), schema: z.coerce.string().default("public"), requiredRows: z.coerce.number().positive().default(2), diff --git a/src/sync/pg-connector.ts b/src/sync/pg-connector.ts index 4613f9f..eea1b93 100644 --- a/src/sync/pg-connector.ts +++ b/src/sync/pg-connector.ts @@ -292,7 +292,7 @@ export class PostgresConnector implements DatabaseConnector { ",\n " )} from (select * from ${doubleQuote( table - )} where ctid = any($1::tid[]))`; + )} where ctid = any($1::tid[])) as samples`; const serialized = await this.sql.unsafe(query, [allCtids]); const estimate = this.tupleEstimates.get(table) ?? "?";