private MySqlCommand BuildAcquireLeasesCommand()

in src/TriggersBinding/MySqlTableChangeMonitor.cs [717:733]


        private MySqlCommand BuildAcquireLeasesCommand(MySqlConnection connection, MySqlTransaction transaction, IReadOnlyList<IReadOnlyDictionary<string, object>> rows)
        {
            string primaryKeys = string.Join(", ", this._primaryKeyColumnNames);
            string rowDataFormatted = this.BuildRowDataInValuesFormat(rows);

            string acquireLeasesQuery = $@" INSERT INTO {this._leasesTableName}
                                            ({primaryKeys}, {LeasesTableAttemptCountColumnName}, {LeasesTableLeaseExpirationTimeColumnName})
                                        values
                                            {rowDataFormatted}
                                        ON DUPLICATE KEY UPDATE
                                            {LeasesTableAttemptCountColumnName} = {LeasesTableAttemptCountColumnName} + 1,
                                            {LeasesTableLeaseExpirationTimeColumnName} = DATE_ADD({MYSQL_FUNC_CURRENTTIME}, INTERVAL {LeaseIntervalInSeconds} SECOND)
                                        ;";

            var acquireLeasesCommand = new MySqlCommand(acquireLeasesQuery, connection, transaction);
            return acquireLeasesCommand;
        }