New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
issues with upsert and createMany #916
Comments
Hi @barbalex, the issue with |
I'll just piggy-back on this issue as I found (I think) another case where zod is seeing an integer instead of a boolean I have these two tables: CREATE TABLE ingredients_photo_uploads (
id UUID PRIMARY KEY,
created_at TIMESTAMP WITH TIME ZONE NOT NULL,
uploaded_at TIMESTAMP WITH TIME ZONE,
upload_duration_sec FLOAT,
ai_processing_duration_sec FLOAT,
photo_url TEXT
);
CREATE TABLE ingredients (
id UUID PRIMARY KEY,
name TEXT NOT NULL,
is_reviewed BOOLEAN NOT NULL,
fill_level INTEGER NOT NULL,
is_ground BOOLEAN,
ingredients_photo_uploads_id UUID,
FOREIGN KEY (ingredients_photo_uploads_id) REFERENCES ingredients_photo_uploads(id)
);
ALTER TABLE ingredients_photo_uploads ENABLE ELECTRIC;
ALTER TABLE ingredients ENABLE ELECTRIC; And this query: db.ingredients_photo_uploads.liveMany({
orderBy: {
created_at: `asc`,
},
include: {
ingredients: true,
},
}) Which errors with:
|
I tried today with version 0.9.4 and the errors remain |
Hi @barbalex, i've not yet found the time to look into this bug. I hope to find some time soon to investigate further. |
@kevin-dp it's not blocking for me, so no Stress |
I tried today with electric-sql 0.9.6. Upserting now works 😆 |
@barbalex just to confirm - you're getting this error with |
Exactly |
@msfstef I now tried using electric-sql v0.10.1 upsert works (since 0.9.6). createMany still errors with same error: Two remarks:
const chunked = chunkArrayWithMinSize(layerOptions, 500)
for (const chunk of chunked) {
try {
const chunkResult = await db.layer_options.createMany({ data: chunk })
console.log('hello, getCapabilitiesData 5a, chunkResult:', chunkResult)
} catch (error) {
// field value must be a string, number, boolean, null or one of the registered custom value types
console.error('hello, getCapabilitiesData 5b, error:', { error, chunk })
}
}
const chunked = chunkArrayWithMinSize(occurrences, 500)
for (const chunk of chunked) {
await db.occurrences.createMany({
data: chunk,
})
} where occurrences are defined as: CREATE TABLE occurrences(
occurrence_id uuid PRIMARY KEY DEFAULT NULL,
account_id uuid DEFAULT NULL REFERENCES accounts(account_id) ON DELETE CASCADE ON UPDATE CASCADE,
occurrence_import_id uuid DEFAULT NULL REFERENCES occurrence_imports(occurrence_import_id) ON DELETE CASCADE ON UPDATE CASCADE,
place_id uuid DEFAULT NULL REFERENCES places(place_id) ON DELETE SET NULL ON UPDATE CASCADE,
not_to_assign boolean DEFAULT NULL,
comment text DEFAULT NULL,
data jsonb DEFAULT NULL,
id_in_source text DEFAULT NULL,
geometry jsonb DEFAULT NULL,
label text DEFAULT NULL
); while layer_options are defined as: CREATE TYPE layer_options_field_enum AS enum(
'wms_format',
'wms_layer',
'wms_info_format',
'wfs_output_format',
'wfs_layer'
);
CREATE TABLE layer_options(
layer_option_id text PRIMARY KEY DEFAULT NULL,
account_id uuid DEFAULT NULL REFERENCES accounts(account_id) ON DELETE CASCADE ON UPDATE CASCADE,
tile_layer_id uuid DEFAULT NULL REFERENCES tile_layers(tile_layer_id) ON DELETE CASCADE ON UPDATE CASCADE,
vector_layer_id uuid DEFAULT NULL REFERENCES vector_layers(vector_layer_id) ON DELETE CASCADE ON UPDATE CASCADE,
field layer_options_field_enum DEFAULT NULL,
value text DEFAULT NULL,
label text DEFAULT NULL,
queryable boolean DEFAULT NULL,
legend_url text DEFAULT NULL
);
|
Hi @barbalex and @KyleAMathews, i tried reproducing this issue using your examples but didn't manage to reproduce it. I used your exact schemas and in case of Kyle the same query but the issue did not occur. If this is still a problem for you, could you share a reproducible example such that we can further investigate this issue. |
I create about 700 datasets when processing the results of a capabilities query i.e. getting properties of wms layers.
I am adding layer options into this table:
I first built the insertions using create, that was before adding the boolean column
queryable
:Works (also with the boolean column
queryable
) but is slow (takes about 30 seconds) due to the 700 datasets. Also: A wms service can have multiple layers, in this case over 700. Every time a single layer is created, the same 700 layer data is requeried. As this data can change (but rarely does), upsert would be preferrable to create.So I changed the query to use upsert instead. First this worked fine:
Then I added a boolean
queryable
to the table:BANG, this error occurs:
I am not passing numbers to the boolean field, only booleans.
Also, the keys it is not recognizing are defined and as mentioned, it worked when using create.
So I got thinking and decided to first deleteMany, then createMany. Thus circumventing the upsert error. And I was also hoping for it to be a lot faster:
The deletion part works.
But createMany fails:
The text was updated successfully, but these errors were encountered: