@rebasepro/common 0.9.1-canary.d198c11 → 0.9.1-canary.e2fc7b6
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.
- package/dist/index.es.js +21 -10
- package/dist/index.es.js.map +1 -1
- package/dist/util/identity.d.ts +20 -9
- package/package.json +3 -3
- package/src/data/buildRebaseData.ts +5 -1
- package/src/util/identity.ts +20 -9
package/dist/index.es.js
CHANGED
|
@@ -300,12 +300,17 @@ function parseIdValues(idValue, primaryKeys) {
|
|
|
300
300
|
/**
|
|
301
301
|
* The primary keys of a collection, as declared by its properties.
|
|
302
302
|
*
|
|
303
|
-
*
|
|
304
|
-
*
|
|
305
|
-
*
|
|
306
|
-
*
|
|
307
|
-
*
|
|
308
|
-
*
|
|
303
|
+
* This is the only tier both sides can read, because it is the only one written
|
|
304
|
+
* in the config: the postgres driver can also infer keys from the Drizzle
|
|
305
|
+
* schema, which the browser never sees and is never sent — the admin compiles
|
|
306
|
+
* the collection files into its own bundle rather than being served them. A key
|
|
307
|
+
* that lives only in the Drizzle schema is therefore invisible here, and the
|
|
308
|
+
* server says so at boot (`warnOnKeysTheAdminCannotResolve`) naming the `isId`
|
|
309
|
+
* to add.
|
|
310
|
+
*
|
|
311
|
+
* Returns an empty array when a collection declares none, which callers must
|
|
312
|
+
* treat as "not addressable" rather than defaulting to `id`: guessing a key
|
|
313
|
+
* that is not the real one produces confidently wrong addresses.
|
|
309
314
|
*/
|
|
310
315
|
function getDeclaredPrimaryKeys(collection) {
|
|
311
316
|
const properties = collection.properties;
|
|
@@ -330,9 +335,15 @@ function getDeclaredPrimaryKeys(collection) {
|
|
|
330
335
|
* The postgres driver tries, in order: properties marked `isId`; the primary
|
|
331
336
|
* keys of the Drizzle schema; and finally a column literally named `id`. Only
|
|
332
337
|
* the first and last are visible in a `CollectionConfig`, which is what both
|
|
333
|
-
* sides share
|
|
334
|
-
*
|
|
335
|
-
*
|
|
338
|
+
* sides share.
|
|
339
|
+
*
|
|
340
|
+
* So the two agree except on a collection that declares no `isId` and whose key
|
|
341
|
+
* is known only to Drizzle. There, the driver reads the real key, and this
|
|
342
|
+
* either resolves nothing (reported to the console by the caller) or — if the
|
|
343
|
+
* table happens to have an unrelated `id` property — resolves `id`, which is
|
|
344
|
+
* the wrong key and cannot be detected from here: the addresses look right and
|
|
345
|
+
* route wrong. Only the config can settle it, so the server names both cases
|
|
346
|
+
* at boot (`warnOnKeysTheAdminCannotResolve`) with the `isId` to add.
|
|
336
347
|
*/
|
|
337
348
|
function resolvePrimaryKeys(collection) {
|
|
338
349
|
const declared = getDeclaredPrimaryKeys(collection);
|
|
@@ -3214,7 +3225,7 @@ function createPrimaryKeyResolver(options) {
|
|
|
3214
3225
|
}
|
|
3215
3226
|
if (!warned.has(slug)) {
|
|
3216
3227
|
warned.add(slug);
|
|
3217
|
-
console.warn(`[rebase] Collection '${slug}' declares no primary key, so its rows have no address: detail links, caching and relations will not work for it. Mark the key property with \`isId\` in its collection config.`);
|
|
3228
|
+
console.warn(`[rebase] Collection '${slug}' declares no primary key, so its rows have no address: detail links, caching and relations will not work for it. Mark the key property with \`isId\` in its collection config — the server logs which column to mark at boot, if its schema knows the key.`);
|
|
3218
3229
|
}
|
|
3219
3230
|
return keys;
|
|
3220
3231
|
};
|