# Created\_at not populated with default value during insert in CrateDB via C#

**URL:** <https://community.cratedb.com/t/created-at-not-populated-with-default-value-during-insert-in-cratedb-via-c/2064>\
**Category:** SQL\
**Tags:** sql\
**Created:** [August 14, 2025, 6:15am UTC](https://community.cratedb.com/t/created-at-not-populated-with-default-value-during-insert-in-cratedb-via-c/2064 "2025-08-14T06:15:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ayas\_Rasheed](https://sea2.discourse-cdn.com/flex020/user_avatar/community.cratedb.com/ayas_rasheed/32/1370_2.png) [@Ayas\_Rasheed](https://community.cratedb.com/u/Ayas_Rasheed)\
**Post date:** [August 14, 2025, 6:15am UTC](https://community.cratedb.com/t/created-at-not-populated-with-default-value-during-insert-in-cratedb-via-c/2064/1 "2025-08-14T06:15:21Z")

</div>

```auto
CREATE TABLE IF NOT EXISTS issue (
    object_id TEXT, -- stores Guid as string
    element_type_id TEXT,
    tag_name TEXT,
    tag_ts TIMESTAMP, -- from TagTs
    ingest_ts TIMESTAMP, -- from IngestTs

    value_data OBJECT(DYNAMIC) AS (
        float_value DOUBLE PRECISION,
        int_value BIGINT,
        bool_value BOOLEAN,
        text_value TEXT,
        json_value TEXT
    ),

    partition_key TIMESTAMP WITH TIME ZONE GENERATED ALWAYS AS date_trunc('month', tag_ts),
    created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,

    PRIMARY KEY (object_id, tag_name, tag_ts, partition_key)
)
CLUSTERED INTO 4 SHARDS
PARTITIONED BY (partition_key)
WITH (number_of_replicas = 1);

```

Insert Statement (via Npgsql C# connector)

`INSERT INTO symx_telemetry_opt_default_issue`  
`(object_id, element_type_id, tag_name, tag_ts, ingest_ts, value_data)`  
`VALUES {string.Join(", ", insertValues)}`  
`ON CONFLICT (object_id, tag_name, tag_ts, partition_key)`  
`DO UPDATE SET`  
`value_data = EXCLUDED.value_data,`  
`ingest_ts = EXCLUDED.ingest_ts;`

#### Problem

- The column `created_at` is defined with `DEFAULT CURRENT_TIMESTAMP`.

- **When inserting new rows (no conflict), `created_at` is still `NULL`.**

- On conflict updates, `created_at` also remains `NULL`.

#### Expected Behavior

- On fresh inserts (no conflict), `created_at` should be automatically populated with the current timestamp from `DEFAULT CURRENT_TIMESTAMP`.

- On conflict updates, `created_at` should retain its previously set value and not be reset to `NULL`.

#### Notes

This behavior was not observed in previous CrateDB versions.  
Previous version used : **5.9.13**  
Current version : **5.10.11**  
Npgsql : **9.0.3**

- The default expression (`DEFAULT CURRENT_TIMESTAMP`) seems to be ignored entirely when inserting through the Npgsql connector.

---

<div class="post-metadata">

**Author:** ![karynsaz](https://sea2.discourse-cdn.com/flex020/user_avatar/community.cratedb.com/karynsaz/32/611_2.png) [@karynsaz](https://community.cratedb.com/u/karynsaz)\
**Post date:** [August 14, 2025, 8:25am UTC](https://community.cratedb.com/t/created-at-not-populated-with-default-value-during-insert-in-cratedb-via-c/2064/2 "2025-08-14T08:25:50Z")

</div>

Hi Ayas,

We have identified this issue in version 5.10.11 already and the fix is on the making, check it here [Generated timestamp column becomes NULL when updating records · Issue #18219 · crate/crate · GitHub](https://github.com/crate/crate/issues/18219) - even though the bug description refers to the generated column, you may find in the comments a reference to `DEFAULT` values as well. I’d suggest you follow the issue in Github to get the latest developments.

In summary, this is a bug in CrateDB related to the `UPDATE` statement, unrelated to Npgsql.

Thank you,

Karyn Azevedo
