最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

google cloud platform - False and 0 Values Not Inserted in PostgreSQL via Wix Velo bulkInsert - Stack Overflow

programmeradmin2浏览0评论

I’m using Wix Velo to insert data into a PostgreSQL database. Everything works except for the integer 0 and the boolean false. These values are not stored correctly in the table and are instead left empty. Here’s the situation:

PostgreSQL Table Structure:

CREATE TABLE jouw_tabel1 (
    "_id",
    "_createdDate" TIMESTAMP,
    "_updatedDate" TIMESTAMP,
    "_owner" VARCHAR(255),
    "numeric_value" INTEGER,
    "is_active" BOOLEAN
);

Wix Velo Code for Insert:

const records = [
    { numeric_value: 0, is_active: true },
    { numeric_value: 0, is_active: false },
    { numeric_value: 1, is_active: false }
];

wixData.bulkInsert("wix_velo_gcp_connection/jouw_tabel1", records)
    .then((result) => {
        console.log(`Successfully inserted ${result.inserted}`);
    })
    .catch((err) => {
        console.error("Error:", err);
    });

What Happens:

  • Non-zero integers and true values are inserted correctly.
  • numeric_value: 0 and is_active: false are not stored and result in empty fields in the database.

What I Know:

  • If I manually insert 0 or false via a SQL prompt (outside of Wix), it works as expected.
  • This suggests the issue likely lies with how Wix Velo processes and sends these values to PostgreSQL.

Troubleshooting Steps Taken:

  • Verified table structure with SELECT column_name, data_type, is_nullable FROM information_schema.columns.
  • Ran queries to fetch records with 0 or false values (e.g., SELECT * FROM jouw_tabel1 WHERE numeric_value = 0;). These return no results.
  • Wix does not show errors during insertion, and there are no obvious logs in PostgreSQL indicating a problem.

I’m using PostgreSQL 16.6. Is there something specific in Wix Velo that could cause this behavior? How can I debug or fix this issue?

Images related to the comments of Adrian Klaver

Query Insights

Query ID: 8155776421138895221 Query text: (Truncated to 4500 characters. Customize query length.)

INSERT INTO
  "jouw_tabel1" ("_id",
  "_createdDate",
  "_updatedDate",
  "_owner",
  "numeric_value",
  "is_active")
VALUES
  ($1, $2, $3, $4, $5, $6)

Flags and Parameters

Flags allow you to customize granular aspects of your instance. Changes may require restart. 1. cloudsql.iam_authentication: on 2. log_statement: all 3. log_min_error_statement: info 4. cloudsql.enable_pgaudit: on 5. pgaudit.log_parameter: on

Images related to the answer of KikoZam

I’m using Wix Velo to insert data into a PostgreSQL database. Everything works except for the integer 0 and the boolean false. These values are not stored correctly in the table and are instead left empty. Here’s the situation:

PostgreSQL Table Structure:

CREATE TABLE jouw_tabel1 (
    "_id",
    "_createdDate" TIMESTAMP,
    "_updatedDate" TIMESTAMP,
    "_owner" VARCHAR(255),
    "numeric_value" INTEGER,
    "is_active" BOOLEAN
);

Wix Velo Code for Insert:

const records = [
    { numeric_value: 0, is_active: true },
    { numeric_value: 0, is_active: false },
    { numeric_value: 1, is_active: false }
];

wixData.bulkInsert("wix_velo_gcp_connection/jouw_tabel1", records)
    .then((result) => {
        console.log(`Successfully inserted ${result.inserted}`);
    })
    .catch((err) => {
        console.error("Error:", err);
    });

What Happens:

  • Non-zero integers and true values are inserted correctly.
  • numeric_value: 0 and is_active: false are not stored and result in empty fields in the database.

What I Know:

  • If I manually insert 0 or false via a SQL prompt (outside of Wix), it works as expected.
  • This suggests the issue likely lies with how Wix Velo processes and sends these values to PostgreSQL.

Troubleshooting Steps Taken:

  • Verified table structure with SELECT column_name, data_type, is_nullable FROM information_schema.columns.
  • Ran queries to fetch records with 0 or false values (e.g., SELECT * FROM jouw_tabel1 WHERE numeric_value = 0;). These return no results.
  • Wix does not show errors during insertion, and there are no obvious logs in PostgreSQL indicating a problem.

I’m using PostgreSQL 16.6. Is there something specific in Wix Velo that could cause this behavior? How can I debug or fix this issue?

Images related to the comments of Adrian Klaver

Query Insights

Query ID: 8155776421138895221 Query text: (Truncated to 4500 characters. Customize query length.)

INSERT INTO
  "jouw_tabel1" ("_id",
  "_createdDate",
  "_updatedDate",
  "_owner",
  "numeric_value",
  "is_active")
VALUES
  ($1, $2, $3, $4, $5, $6)

Flags and Parameters

Flags allow you to customize granular aspects of your instance. Changes may require restart. 1. cloudsql.iam_authentication: on 2. log_statement: all 3. log_min_error_statement: info 4. cloudsql.enable_pgaudit: on 5. pgaudit.log_parameter: on

Images related to the answer of KikoZam

Share Improve this question edited Jan 21 at 19:35 Fabian asked Jan 20 at 14:24 FabianFabian 2301 gold badge5 silver badges14 bronze badges 13
  • It is impossible for numeric_value in that table to be empty - you have defined it as NOT NULL. Something about your question doesn't match the reality of the situation. – Richard Huxton Commented Jan 20 at 15:26
  • You are right. I made a mistake. Updated my question and provided info on the schema. – Fabian Commented Jan 20 at 15:34
  • Again your query does not match the data. The insert does not include "_id","_createdDate" and "_updatedDate"" yet there are values returned for those fields. Is there an insert trigger on the table? – Adrian Klaver Commented Jan 20 at 15:56
  • He @AdrianKlaver, thank you for having a look at this. This is default Wix behavior. It's needed to write data to the table. Source: dev.wix.com/docs/develop-websites/articles/databases/… – Fabian Commented Jan 20 at 15:58
  • 1 1) It is a bug in Wix. Postgres does not care: select false::boolean, 'false'::boolean, 0::integer, '0'::integer; f | f | 0 | 0 2) Postgres will not take false for NULL. false is a known value, NULL is unknown. 3) I understand the issue, Wix is broken. – Adrian Klaver Commented Jan 21 at 21:02
 |  Show 8 more comments

1 Answer 1

Reset to default 0

It's possible that the PostgreSQL database schema has a default value for numeric\_value and is\_active that might be overriding the values being sent. Add column\_default to specifically check the default values, if the column\_default is NULL, that means the column doesn't have a default value set. So make sure no default values are set for numeric\_value and is\_active.

Here’s the modified query:

SELECT column_name, data_type, is_nullable, column_default
FROM information_schema.columns
WHERE table_schema = 'public' 
  AND table_name = 'jouw_tabel1';

The result might look like this:

colum_name data_type is_nullable column_default
_id character varying YES NULL
_createdDate timestamp YES CURRENT_TIMESTAMP
_updatedDate timestamp YES CURRENT_TIMESTAMP
_owner character varying YES NULL
numeric_value integer YES NULL
is_active boolean YES NULL
发布评论

评论列表(0)

  1. 暂无评论