@supabase/pg-delta 1.0.0-alpha.8 → 1.0.0-alpha.9
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.
|
@@ -27,7 +27,7 @@ export const declarativeApplyCommand = buildCommand({
|
|
|
27
27
|
parse: Number,
|
|
28
28
|
optional: true,
|
|
29
29
|
},
|
|
30
|
-
"
|
|
30
|
+
"skip-function-validation": {
|
|
31
31
|
kind: "boolean",
|
|
32
32
|
brief: "Skip final function body validation pass",
|
|
33
33
|
optional: true,
|
|
@@ -110,7 +110,7 @@ Tip: Use DEBUG=pg-delta:declarative-apply for detailed defer/skip/fail logs (whi
|
|
|
110
110
|
content,
|
|
111
111
|
targetUrl: flags.target,
|
|
112
112
|
maxRounds: flags["max-rounds"],
|
|
113
|
-
validateFunctionBodies: !flags["
|
|
113
|
+
validateFunctionBodies: !flags["skip-function-validation"],
|
|
114
114
|
onRoundComplete,
|
|
115
115
|
});
|
|
116
116
|
}
|
|
@@ -107,8 +107,49 @@ export function createPool(connectionString, options) {
|
|
|
107
107
|
connectionTimeoutMillis: DEFAULT_CONNECTION_TIMEOUT_MS,
|
|
108
108
|
...config,
|
|
109
109
|
});
|
|
110
|
-
if (onConnect)
|
|
111
|
-
|
|
110
|
+
if (onConnect) {
|
|
111
|
+
const pendingClientSetup = new WeakMap();
|
|
112
|
+
const waitForClientSetup = async (client) => {
|
|
113
|
+
const setup = pendingClientSetup.get(client);
|
|
114
|
+
if (setup) {
|
|
115
|
+
await setup;
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
throw new Error("Internal error: pool client was acquired before async onConnect setup was registered. This indicates a bug in the pool wrapper logic; please report it with reproduction steps.");
|
|
119
|
+
};
|
|
120
|
+
const originalConnect = pool.connect.bind(pool);
|
|
121
|
+
pool.on("connect", (client) => {
|
|
122
|
+
pendingClientSetup.set(client, Promise.resolve().then(() => onConnect(client)));
|
|
123
|
+
});
|
|
124
|
+
pool.connect = ((callback) => {
|
|
125
|
+
if (!callback) {
|
|
126
|
+
return originalConnect().then(async (client) => {
|
|
127
|
+
try {
|
|
128
|
+
await waitForClientSetup(client);
|
|
129
|
+
return client;
|
|
130
|
+
}
|
|
131
|
+
catch (setupError) {
|
|
132
|
+
client.release?.(setupError);
|
|
133
|
+
throw setupError;
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
return originalConnect(async (err, client, release) => {
|
|
138
|
+
if (err || !client) {
|
|
139
|
+
callback(err, client, release);
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
try {
|
|
143
|
+
await waitForClientSetup(client);
|
|
144
|
+
callback(err, client, release);
|
|
145
|
+
}
|
|
146
|
+
catch (setupError) {
|
|
147
|
+
release(setupError);
|
|
148
|
+
callback(setupError, undefined, () => { });
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
}
|
|
112
153
|
if (onError)
|
|
113
154
|
pool.on("error", onError);
|
|
114
155
|
if (onAcquire)
|
package/package.json
CHANGED
|
@@ -42,7 +42,7 @@ export const declarativeApplyCommand = buildCommand({
|
|
|
42
42
|
parse: Number,
|
|
43
43
|
optional: true,
|
|
44
44
|
},
|
|
45
|
-
"
|
|
45
|
+
"skip-function-validation": {
|
|
46
46
|
kind: "boolean",
|
|
47
47
|
brief: "Skip final function body validation pass",
|
|
48
48
|
optional: true,
|
|
@@ -93,7 +93,7 @@ Tip: Use DEBUG=pg-delta:declarative-apply for detailed defer/skip/fail logs (whi
|
|
|
93
93
|
path: string;
|
|
94
94
|
target: string;
|
|
95
95
|
"max-rounds"?: number;
|
|
96
|
-
"
|
|
96
|
+
"skip-function-validation"?: boolean;
|
|
97
97
|
verbose?: boolean;
|
|
98
98
|
"ungroup-diagnostics"?: boolean;
|
|
99
99
|
},
|
|
@@ -144,7 +144,7 @@ Tip: Use DEBUG=pg-delta:declarative-apply for detailed defer/skip/fail logs (whi
|
|
|
144
144
|
content,
|
|
145
145
|
targetUrl: flags.target,
|
|
146
146
|
maxRounds: flags["max-rounds"],
|
|
147
|
-
validateFunctionBodies: !flags["
|
|
147
|
+
validateFunctionBodies: !flags["skip-function-validation"],
|
|
148
148
|
onRoundComplete,
|
|
149
149
|
});
|
|
150
150
|
} catch (error) {
|
|
@@ -139,7 +139,62 @@ export function createPool(
|
|
|
139
139
|
...config,
|
|
140
140
|
});
|
|
141
141
|
|
|
142
|
-
if (onConnect)
|
|
142
|
+
if (onConnect) {
|
|
143
|
+
const pendingClientSetup = new WeakMap<PoolClient, Promise<void>>();
|
|
144
|
+
const waitForClientSetup = async (client: PoolClient) => {
|
|
145
|
+
const setup = pendingClientSetup.get(client);
|
|
146
|
+
if (setup) {
|
|
147
|
+
await setup;
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
throw new Error(
|
|
151
|
+
"Internal error: pool client was acquired before async onConnect setup was registered. This indicates a bug in the pool wrapper logic; please report it with reproduction steps.",
|
|
152
|
+
);
|
|
153
|
+
};
|
|
154
|
+
const originalConnect = pool.connect.bind(pool);
|
|
155
|
+
|
|
156
|
+
pool.on("connect", (client) => {
|
|
157
|
+
pendingClientSetup.set(
|
|
158
|
+
client,
|
|
159
|
+
Promise.resolve().then(() => onConnect(client)),
|
|
160
|
+
);
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
pool.connect = ((
|
|
164
|
+
callback?: (
|
|
165
|
+
err: Error | undefined,
|
|
166
|
+
client: PoolClient | undefined,
|
|
167
|
+
release: (err?: Error | boolean) => void,
|
|
168
|
+
) => void,
|
|
169
|
+
) => {
|
|
170
|
+
if (!callback) {
|
|
171
|
+
return originalConnect().then(async (client) => {
|
|
172
|
+
try {
|
|
173
|
+
await waitForClientSetup(client);
|
|
174
|
+
return client;
|
|
175
|
+
} catch (setupError) {
|
|
176
|
+
(client as PoolClient).release?.(setupError as Error);
|
|
177
|
+
throw setupError;
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return originalConnect(async (err, client, release) => {
|
|
183
|
+
if (err || !client) {
|
|
184
|
+
callback(err, client, release);
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
try {
|
|
189
|
+
await waitForClientSetup(client);
|
|
190
|
+
callback(err, client, release);
|
|
191
|
+
} catch (setupError) {
|
|
192
|
+
release(setupError as Error);
|
|
193
|
+
callback(setupError as Error, undefined, () => {});
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
}) as Pool["connect"];
|
|
197
|
+
}
|
|
143
198
|
if (onError) pool.on("error", onError);
|
|
144
199
|
if (onAcquire) pool.on("acquire", onAcquire);
|
|
145
200
|
if (onRemove) pool.on("remove", onRemove);
|