diff options
| author | Dan Goodliffe <dan@randomdan.homeip.net> | 2026-04-18 01:00:42 +0100 |
|---|---|---|
| committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2026-04-18 01:00:42 +0100 |
| commit | 7b148411b127ebf6fdefdb1b0decd2886cdfc17b (patch) | |
| tree | 56385615fe86dbb5ab7ce4a90d696d97ddf21d7e /src/sql | |
| parent | 1e551e618a63c869fde6a4b327566b38696a5f45 (diff) | |
| parent | fa6074eaf52be4254c17b74f20193aa96c940df8 (diff) | |
| download | webstat-7b148411b127ebf6fdefdb1b0decd2886cdfc17b.tar.bz2 webstat-7b148411b127ebf6fdefdb1b0decd2886cdfc17b.tar.xz webstat-7b148411b127ebf6fdefdb1b0decd2886cdfc17b.zip | |
Merge remote-tracking branch 'origin/no-crc32'HEADwebstat-0.4main
Diffstat (limited to 'src/sql')
| -rw-r--r-- | src/sql/entityInsert.sql | 6 | ||||
| -rw-r--r-- | src/sql/hostUpsert.sql | 14 |
2 files changed, 10 insertions, 10 deletions
diff --git a/src/sql/entityInsert.sql b/src/sql/entityInsert.sql index 8e25810..f518617 100644 --- a/src/sql/entityInsert.sql +++ b/src/sql/entityInsert.sql @@ -1,4 +1,2 @@ -INSERT INTO entities(id, type, value) - VALUES (?, ?, ?) -ON CONFLICT - DO NOTHING +SELECT + entity(?, ?) diff --git a/src/sql/hostUpsert.sql b/src/sql/hostUpsert.sql index 18e8df8..d5ee11d 100644 --- a/src/sql/hostUpsert.sql +++ b/src/sql/hostUpsert.sql @@ -1,7 +1,9 @@ -INSERT INTO entities(id, type, value, detail) - VALUES ($1, 'host', $2, jsonb_build_object('sysname', $3::text, 'release', $4::text, - 'version', $5::text, 'machine', $6::text, 'domainname', $7::text)) -ON CONFLICT ON CONSTRAINT pk_entities +INSERT INTO entities(type, value, detail) + VALUES ('host', $1, jsonb_build_object('sysname', $2::text, 'release', $3::text, + 'version', $4::text, 'machine', $5::text, 'domainname', $6::text)) +ON CONFLICT (md5(value)) DO UPDATE SET - detail = jsonb_build_object('sysname', $3::text, 'release', $4::text, 'version', - $5::text, 'machine', $6::text, 'domainname', $7::text) + detail = jsonb_build_object('sysname', $2::text, 'release', $3::text, 'version', + $4::text, 'machine', $5::text, 'domainname', $6::text) + RETURNING + id |
