20470: Restore error selecting on invalid fields
[arvados.git] / services / api / lib / db_current_time.rb
1 # Copyright (C) The Arvados Authors. All rights reserved.
2 #
3 # SPDX-License-Identifier: AGPL-3.0
4
5 module DbCurrentTime
6   CURRENT_TIME_SQL = "SELECT clock_timestamp() AT TIME ZONE 'UTC'"
7
8   def db_current_time
9     Time.parse(ActiveRecord::Base.connection.select_value(CURRENT_TIME_SQL) + " +0000")
10   end
11
12   def db_transaction_time
13     Time.parse(ActiveRecord::Base.connection.select_value("SELECT current_timestamp AT TIME ZONE 'UTC'") + " +0000")
14   end
15 end