Skip to content

Commit

Permalink
repo-sqale: use of "timestamp" instead of "timestampValue" columns
Browse files Browse the repository at this point in the history
  • Loading branch information
virgo47 committed Aug 26, 2021
1 parent b651c4e commit dbe5a88
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 25 deletions.
4 changes: 2 additions & 2 deletions repo/repo-sqale/sql/pgnew-repo-audit.sql
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ CREATE INDEX ma_audit_ref_recordId_timestamp_idx ON ma_audit_ref (recordId, time
/* TODO audit indexes
CREATE INDEX iAuditDeltaRecordId
ON m_audit_delta (record_id);
CREATE INDEX iTimestampValue
ON m_audit_event (timestampValue);
CREATE INDEX iTimestamp
ON m_audit_event (timestamp);
CREATE INDEX iAuditEventRecordEStageTOid
ON m_audit_event (eventStage, targetOid);
CREATE INDEX iChangedItemPath
Expand Down
8 changes: 4 additions & 4 deletions repo/repo-sqale/sql/pgnew-repo.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1637,13 +1637,13 @@ CREATE TABLE m_trigger (
containerType ContainerType GENERATED ALWAYS AS ('TRIGGER') STORED
CHECK (containerType = 'TRIGGER'),
handlerUriId INTEGER REFERENCES m_uri(id),
timestampValue TIMESTAMPTZ,
timestamp TIMESTAMPTZ,

PRIMARY KEY (ownerOid, cid)
)
INHERITS(m_container);

CREATE INDEX m_trigger_timestampValue_idx ON m_trigger (timestampValue);
CREATE INDEX m_trigger_timestamp_idx ON m_trigger (timestamp);

-- stores ObjectType/operationExecution (OperationExecutionType)
CREATE TABLE m_operation_execution (
Expand All @@ -1658,7 +1658,7 @@ CREATE TABLE m_operation_execution (
taskRefTargetOid UUID,
taskRefTargetType ObjectType,
taskRefRelationId INTEGER REFERENCES m_uri(id),
timestampValue TIMESTAMPTZ,
timestamp TIMESTAMPTZ,

PRIMARY KEY (ownerOid, cid)
)
Expand All @@ -1668,7 +1668,7 @@ CREATE INDEX m_operation_execution_initiatorRefTargetOid_idx
ON m_operation_execution (initiatorRefTargetOid);
CREATE INDEX m_operation_execution_taskRefTargetOid_idx
ON m_operation_execution (taskRefTargetOid);
CREATE INDEX m_operation_execution_timestampValue_idx ON m_operation_execution (timestampValue);
CREATE INDEX m_operation_execution_timestamp_idx ON m_operation_execution (timestamp);
-- index for ownerOid is part of PK
-- TODO: index for status is questionable, don't we want WHERE status = ... to another index instead?
-- endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class QAuditEventRecord extends FlexibleRelationalPathBase<MAuditEventRec
public static final ColumnMetadata ID =
ColumnMetadata.named("id").ofType(Types.BIGINT).notNull();
public static final ColumnMetadata TIMESTAMP =
ColumnMetadata.named("timestampValue").ofType(Types.TIMESTAMP_WITH_TIMEZONE).notNull();
ColumnMetadata.named("timestamp").ofType(Types.TIMESTAMP_WITH_TIMEZONE).notNull();
public static final ColumnMetadata EVENT_IDENTIFIER =
ColumnMetadata.named("eventIdentifier").ofType(Types.VARCHAR);
public static final ColumnMetadata EVENT_TYPE =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ public class MOperationExecution extends MContainer {
public UUID taskRefTargetOid;
public MObjectType taskRefTargetType;
public Integer taskRefRelationId;
public Instant timestampValue;
public Instant timestamp;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
public class MTrigger extends MContainer {

public Integer handlerUriId;
public Instant timestampValue;
public Instant timestamp;
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ public class QOperationExecution<OR extends MObject> extends QContainer<MOperati
ColumnMetadata.named("taskRefTargetType").ofType(Types.OTHER);
public static final ColumnMetadata TASK_REF_RELATION_ID =
ColumnMetadata.named("taskRefRelationId").ofType(Types.INTEGER);
public static final ColumnMetadata TIMESTAMP_VALUE =
ColumnMetadata.named("timestampValue").ofType(Types.TIMESTAMP_WITH_TIMEZONE);
public static final ColumnMetadata TIMESTAMP =
ColumnMetadata.named("timestamp").ofType(Types.TIMESTAMP_WITH_TIMEZONE);

// attributes

Expand All @@ -75,8 +75,8 @@ public class QOperationExecution<OR extends MObject> extends QContainer<MOperati
createEnum("taskRefTargetType", MObjectType.class, TASK_REF_TARGET_TYPE);
public final NumberPath<Integer> taskRefRelationId =
createInteger("taskRefRelationId", TASK_REF_RELATION_ID);
public final DateTimePath<Instant> timestampValue =
createInstant("timestampValue", TIMESTAMP_VALUE);
public final DateTimePath<Instant> timestamp =
createInstant("timestamp", TIMESTAMP);

public QOperationExecution(String variable) {
this(variable, DEFAULT_SCHEMA_NAME, TABLE_NAME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private QOperationExecutionMapping(@NotNull SqaleRepoContext repositoryContext)
q -> q.taskRefRelationId,
QTaskMapping::get);
addItemMapping(OperationExecutionType.F_TIMESTAMP,
timestampMapper(q -> q.timestampValue));
timestampMapper(q -> q.timestamp));
}

@Override
Expand Down Expand Up @@ -106,7 +106,7 @@ public MOperationExecution insert(
o -> row.taskRefTargetOid = o,
t -> row.taskRefTargetType = t,
r -> row.taskRefRelationId = r);
row.timestampValue = MiscUtil.asInstant(schemaObject.getTimestamp());
row.timestamp = MiscUtil.asInstant(schemaObject.getTimestamp());

insert(row, jdbcSession);
return row;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,13 @@ public class QTrigger<OR extends MObject> extends QContainer<MTrigger, OR> {

public static final ColumnMetadata HANDLER_URI_ID =
ColumnMetadata.named("handlerUriId").ofType(Types.INTEGER);
public static final ColumnMetadata TIMESTAMP_VALUE =
ColumnMetadata.named("timestampValue").ofType(Types.TIMESTAMP_WITH_TIMEZONE);
public static final ColumnMetadata TIMESTAMP =
ColumnMetadata.named("timestamp").ofType(Types.TIMESTAMP_WITH_TIMEZONE);

// attributes

public final NumberPath<Integer> handlerUriId = createInteger("handlerUriId", HANDLER_URI_ID);
public final DateTimePath<Instant> timestampValue =
createInstant("timestampValue", TIMESTAMP_VALUE);
public final DateTimePath<Instant> timestamp = createInstant("timestamp", TIMESTAMP);

public QTrigger(String variable) {
this(variable, DEFAULT_SCHEMA_NAME, TABLE_NAME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private QTriggerMapping(@NotNull SqaleRepoContext repositoryContext) {
(q, p) -> q.ownerOid.eq(p.oid)));

addItemMapping(TriggerType.F_HANDLER_URI, uriMapper(q -> q.handlerUriId));
addItemMapping(TriggerType.F_TIMESTAMP, timestampMapper(q -> q.timestampValue));
addItemMapping(TriggerType.F_TIMESTAMP, timestampMapper(q -> q.timestamp));
}

@Override
Expand All @@ -80,7 +80,7 @@ public MTrigger insert(TriggerType schemaObject, OR ownerRow, JdbcSession jdbcSe
MTrigger row = initRowObject(schemaObject, ownerRow);

row.handlerUriId = processCacheableUri(schemaObject.getHandlerUri());
row.timestampValue = MiscUtil.asInstant(schemaObject.getTimestamp());
row.timestamp = MiscUtil.asInstant(schemaObject.getTimestamp());

insert(row, jdbcSession);
return row;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1022,12 +1022,12 @@ public void test801ContainerTrigger() throws Exception {
MTrigger containerRow = containers.get(0);
assertThat(containerRow.cid).isEqualTo(3); // assigned in advance
assertCachedUri(containerRow.handlerUriId, "trigger-1-handler-uri");
assertThat(containerRow.timestampValue).isEqualTo(Instant.ofEpochMilli(1));
assertThat(containerRow.timestamp).isEqualTo(Instant.ofEpochMilli(1));

containerRow = containers.get(1);
assertThat(containerRow.cid).isEqualTo(4); // next CID assigned by repo
assertCachedUri(containerRow.handlerUriId, "trigger-2-handler-uri");
assertThat(containerRow.timestampValue).isEqualTo(Instant.ofEpochMilli(2));
assertThat(containerRow.timestamp).isEqualTo(Instant.ofEpochMilli(2));

MObject objectRow = selectObjectByOid(
QSystemConfiguration.class, systemConfiguration.getOid());
Expand Down Expand Up @@ -1079,12 +1079,12 @@ public void test802ContainerOperationExecution() throws Exception {
assertThat(containerRow.taskRefTargetOid).isEqualTo(taskRefOid);
assertThat(containerRow.taskRefTargetType).isEqualTo(MObjectType.TASK);
assertCachedUri(containerRow.taskRefRelationId, taskRelation);
assertThat(containerRow.timestampValue).isEqualTo(Instant.ofEpochMilli(1));
assertThat(containerRow.timestamp).isEqualTo(Instant.ofEpochMilli(1));

containerRow = containers.get(1);
assertThat(containerRow.cid).isEqualTo(2);
assertThat(containerRow.status).isEqualTo(OperationResultStatusType.UNKNOWN);
assertThat(containerRow.timestampValue).isEqualTo(Instant.ofEpochMilli(2));
assertThat(containerRow.timestamp).isEqualTo(Instant.ofEpochMilli(2));

// this time we didn't test assigned CID or CID SEQ value on owner (see test801)
}
Expand Down

0 comments on commit dbe5a88

Please sign in to comment.