roryqi commented on code in PR #12354:
URL: https://github.com/apache/gravitino/pull/12354#discussion_r3719334011
##########
scripts/postgresql/schema-2.0.0-postgresql.sql:
##########
@@ -523,21 +525,23 @@ CREATE TABLE IF NOT EXISTS tag_relation_meta (
tag_id BIGINT NOT NULL,
metadata_object_id BIGINT NOT NULL,
metadata_object_type VARCHAR(64) NOT NULL,
+ tag_value VARCHAR(256) DEFAULT NULL,
audit_info TEXT NOT NULL,
current_version INT NOT NULL DEFAULT 1,
last_version INT NOT NULL DEFAULT 1,
deleted_at BIGINT NOT NULL DEFAULT 0,
- PRIMARY KEY (id),
- UNIQUE (tag_id, metadata_object_id, metadata_object_type, deleted_at)
+ PRIMARY KEY (id)
Review Comment:
Implemented in f71245cff. `tag_value` is now `NOT NULL DEFAULT ''`, and
valueless assignments are normalized to the empty string before persistence.
The database uniqueness key is `(tag_id, metadata_object_id,
metadata_object_type, tag_value, deleted_at)` in the MySQL, H2, and PostgreSQL
schemas and upgrade scripts. I also added a database-level regression test that
attempts to insert a duplicate active valueless relation and verifies that the
constraint rejects it; the relevant tests pass on all three database backends.
##########
scripts/mysql/schema-2.0.0-mysql.sql:
##########
@@ -299,14 +300,16 @@ CREATE TABLE IF NOT EXISTS `tag_relation_meta` (
`tag_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'tag id',
`metadata_object_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'metadata object
id',
`metadata_object_type` VARCHAR(64) NOT NULL COMMENT 'metadata object type',
+ `tag_value` VARCHAR(256) NOT NULL DEFAULT '' COMMENT 'tag assignment
value, empty string means no value',
`audit_info` MEDIUMTEXT NOT NULL COMMENT 'tag relation audit info',
`current_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'tag relation
current version',
`last_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'tag relation last
version',
`deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'tag relation
deleted at',
PRIMARY KEY (`id`),
- UNIQUE KEY `uk_ti_mi_mo_del` (`tag_id`, `metadata_object_id`,
`metadata_object_type`, `deleted_at`),
+ UNIQUE KEY `uk_ti_mi_mo_tv_del` (`tag_id`, `metadata_object_id`,
`metadata_object_type`, `tag_value`, `deleted_at`),
Review Comment:
The updated definition is `tag_value VARCHAR(256) NOT NULL DEFAULT ''`, so
`NULL` cannot be stored. The persistence converter also normalizes the API
no-value case to `''`. Therefore two otherwise identical valueless rows have
the same non-null `tag_value` and are rejected by `uk_ti_mi_mo_tv_del`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]