public SqliteQueryExecutor(QueryConfiguration configuration, Akka.Serialization.Serialization serialization, ITimestampProvider timestampProvider) : base(configuration, serialization, timestampProvider) { ByTagSql = base.ByTagSql + " LIMIT @Take"; CreateEventsJournalSql = $@" CREATE TABLE IF NOT EXISTS {configuration.FullJournalTableName} ( {configuration.OrderingColumnName} INTEGER PRIMARY KEY NOT NULL, {configuration.PersistenceIdColumnName} VARCHAR(255) NOT NULL, {configuration.SequenceNrColumnName} INTEGER(8) NOT NULL, {configuration.IsDeletedColumnName} INTEGER(1) NOT NULL, {configuration.ManifestColumnName} VARCHAR(255) NULL, {configuration.TimestampColumnName} INTEGER NOT NULL, {configuration.PayloadColumnName} BLOB NOT NULL, {configuration.TagsColumnName} VARCHAR(2000) NULL, UNIQUE ({configuration.PersistenceIdColumnName}, {configuration.SequenceNrColumnName}) );"; CreateMetaTableSql = $@" CREATE TABLE IF NOT EXISTS {configuration.FullMetaTableName} ( {configuration.PersistenceIdColumnName} VARCHAR(255) NOT NULL, {configuration.SequenceNrColumnName} INTEGER(8) NOT NULL, PRIMARY KEY ({configuration.PersistenceIdColumnName}, {configuration.SequenceNrColumnName}) );"; }
/// <summary> /// TBD /// </summary> /// <param name="configuration">TBD</param> /// <param name="serialization">TBD</param> /// <param name="timestampProvider">TBD</param> protected AbstractQueryExecutor(QueryConfiguration configuration, Akka.Serialization.Serialization serialization, ITimestampProvider timestampProvider) { TimestampProvider = timestampProvider; Serialization = serialization; Configuration = configuration; var allEventColumnNames = $@" e.{Configuration.PersistenceIdColumnName} as PersistenceId, e.{Configuration.SequenceNrColumnName} as SequenceNr, e.{Configuration.TimestampColumnName} as Timestamp, e.{Configuration.IsDeletedColumnName} as IsDeleted, e.{Configuration.ManifestColumnName} as Manifest, e.{Configuration.PayloadColumnName} as Payload"; AllPersistenceIdsSql = $@" SELECT DISTINCT e.{Configuration.PersistenceIdColumnName} as PersistenceId FROM {Configuration.FullJournalTableName} e;"; HighestSequenceNrSql = $@" SELECT MAX(u.SeqNr) as SequenceNr FROM ( SELECT e.{Configuration.SequenceNrColumnName} as SeqNr FROM {Configuration.FullJournalTableName} e WHERE e.{Configuration.PersistenceIdColumnName} = @PersistenceId UNION SELECT m.{Configuration.SequenceNrColumnName} as SeqNr FROM {Configuration.FullMetaTableName} m WHERE m.{Configuration.PersistenceIdColumnName} = @PersistenceId) as u"; DeleteBatchSql = $@" DELETE FROM {Configuration.FullJournalTableName} WHERE {Configuration.PersistenceIdColumnName} = @PersistenceId AND {Configuration.SequenceNrColumnName} <= @ToSequenceNr;"; UpdateSequenceNrSql = $@" INSERT INTO {Configuration.FullMetaTableName} ({Configuration.PersistenceIdColumnName}, {Configuration.SequenceNrColumnName}) VALUES (@PersistenceId, @SequenceNr);"; ByPersistenceIdSql = $@" SELECT {allEventColumnNames} FROM {Configuration.FullJournalTableName} e WHERE e.{Configuration.PersistenceIdColumnName} = @PersistenceId AND e.{Configuration.SequenceNrColumnName} BETWEEN @FromSequenceNr AND @ToSequenceNr ORDER BY {Configuration.SequenceNrColumnName} ASC;"; ByTagSql = $@" SELECT {allEventColumnNames}, e.{Configuration.OrderingColumnName} as Ordering FROM {Configuration.FullJournalTableName} e WHERE e.{Configuration.OrderingColumnName} > @Ordering AND e.{Configuration.TagsColumnName} LIKE @Tag ORDER BY {Configuration.OrderingColumnName} ASC"; InsertEventSql = $@" INSERT INTO {Configuration.FullJournalTableName} ( {Configuration.PersistenceIdColumnName}, {Configuration.SequenceNrColumnName}, {Configuration.TimestampColumnName}, {Configuration.IsDeletedColumnName}, {Configuration.ManifestColumnName}, {Configuration.PayloadColumnName}, {Configuration.TagsColumnName} ) VALUES ( @PersistenceId, @SequenceNr, @Timestamp, @IsDeleted, @Manifest, @Payload, @Tag )"; QueryEventsSql = $@" SELECT {allEventColumnNames} FROM {Configuration.FullJournalTableName} e WHERE "; }
protected AbstractQueryExecutor(QueryConfiguration configuration, Akka.Serialization.Serialization serialization, ITimestampProvider timestampProvider) { TimestampProvider = timestampProvider; Serialization = serialization; Configuration = configuration; var allEventColumnNames = $@" e.{Configuration.PersistenceIdColumnName} as PersistenceId, e.{Configuration.SequenceNrColumnName} as SequenceNr, e.{Configuration.TimestampColumnName} as Timestamp, e.{Configuration.IsDeletedColumnName} as IsDeleted, e.{Configuration.ManifestColumnName} as Manifest, e.{Configuration.PayloadColumnName} as Payload"; AllPersistenceIdsSql = $@" SELECT DISTINCT e.{Configuration.PersistenceIdColumnName} as PersistenceId FROM {Configuration.FullJournalTableName} e;"; HighestSequenceNrSql = $@" SELECT MAX(u.SeqNr) as SequenceNr FROM ( SELECT e.{Configuration.SequenceNrColumnName} as SeqNr FROM {Configuration.FullJournalTableName} e WHERE e.{Configuration.PersistenceIdColumnName} = @PersistenceId UNION SELECT m.{Configuration.SequenceNrColumnName} as SeqNr FROM {Configuration.FullMetaTableName} m WHERE m.{Configuration.PersistenceIdColumnName} = @PersistenceId) as u"; DeleteBatchSql = $@" DELETE FROM {Configuration.FullJournalTableName} WHERE {Configuration.PersistenceIdColumnName} = @PersistenceId AND {Configuration.SequenceNrColumnName} <= @ToSequenceNr;"; UpdateSequenceNrSql = $@" INSERT INTO {Configuration.FullMetaTableName} ({Configuration.PersistenceIdColumnName}, {Configuration.SequenceNrColumnName}) VALUES (@PersistenceId, @SequenceNr);"; ByPersistenceIdSql = $@" SELECT {allEventColumnNames} FROM {Configuration.FullJournalTableName} e WHERE e.{Configuration.PersistenceIdColumnName} = @PersistenceId AND e.{Configuration.SequenceNrColumnName} BETWEEN @FromSequenceNr AND @ToSequenceNr;"; ByTagSql = $@" SELECT {allEventColumnNames}, e.{Configuration.OrderingColumnName} as Ordering FROM {Configuration.FullJournalTableName} e WHERE e.{Configuration.OrderingColumnName} > @Ordering AND e.{Configuration.TagsColumnName} LIKE @Tag ORDER BY {Configuration.OrderingColumnName} ASC"; InsertEventSql = $@" INSERT INTO {Configuration.FullJournalTableName} ( {Configuration.PersistenceIdColumnName}, {Configuration.SequenceNrColumnName}, {Configuration.TimestampColumnName}, {Configuration.IsDeletedColumnName}, {Configuration.ManifestColumnName}, {Configuration.PayloadColumnName}, {Configuration.TagsColumnName} ) VALUES ( @PersistenceId, @SequenceNr, @Timestamp, @IsDeleted, @Manifest, @Payload, @Tag )"; QueryEventsSql = $@" SELECT {allEventColumnNames} FROM {Configuration.FullJournalTableName} e WHERE "; }