Page MenuHomePhabricator

Cargo: #cargo_store fails when non-mandatory Boolean/Integer/Float fields are omitted, because it tries to insert empty string into INTEGER field, etc.
Open, HighPublicBUG REPORT

Description

Using the following #cargo_store directive:

{{#cargo_store:_table = statuseffect
|id=isn_lowfrictionstrip
|name=Low Friction Strip
|defaultDuration=0.2
}}

... on the following table:

{{#cargo_declare:
_table = statuseffect
|id = String
|name = String
|defaultDuration = Float
|hasIcon = Boolean
}}

... results in a SQL error:

Error 1366: Incorrect integer value: '' for column `frackinuniversewiki`.`cargo__statuseffect__NEXT`.`hasIcon` at row 1 (db11.miraheze.org)
Function: Wikimedia\Rdbms\Database::insert
Query: INSERT INTO `cargo__statuseffect__NEXT` (`id`,`name`,`defaultDuration`,`hasIcon`,`_pageName`,`_pageTitle`,`_pageNamespace`,`_pageID`,`_ID`) VALUES ('isn_lowfrictionstrip','Low Friction Strip','0.2','','Template:Cargo/status/Chunk4','Cargo/status/Chunk4',10,45685,1)

As you can see, empty string is being inserted into hasIcon column of SQL table (which doesn't allow strings). Should probably be NULL instead of empty string.

Noticed here: https://phabricator.miraheze.org/T7493

Event Timeline

Restricted Application added subscribers: RhinosF1, Reception123, Aklapper. · View Herald Transcript
Bongo-Cat added a subscriber: Bongo-Cat.

Until this is fixed, one non-ideal workaround for this issue is turning strict mode off on the database server.

Are you sure this isn't fixed already? I would like, if possible, to get confirmation that this is still a problem with the latest Cargo code (version 3.0).

Are you sure this isn't fixed already? I would like, if possible, to get confirmation that this is still a problem with the latest Cargo code (version 3.0).

Nookipedia experiences this issue with 2.8; we plan to upgrade to 3.0 in the next 1-2 weeks, will report back after testing.