Skip to content

Commit

Permalink
Use the floor rounding for PostgreSQL timestamps.
Browse files Browse the repository at this point in the history
  • Loading branch information
pat committed Jun 8, 2012
1 parent ceb0bc8 commit 07c2c29
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions HISTORY
@@ -1,3 +1,7 @@
Edge:
* Cast PostgreSQL timestamps to their floored integers (instead of rounding up).
* Don't add array_accum to PostgreSQL v80311 (8.3.?) or newer.

1.4.12 - May 14th 2012
* Updating Riddle references to 1.5.2.
* Can explicitly specify available types for STI tables instead of automatically discovering them with "SELECT DISTINCT type FROM <table>" (Cedric Maion).
Expand Down
4 changes: 2 additions & 2 deletions lib/thinking_sphinx/adapters/postgresql_adapter.rb
Expand Up @@ -33,9 +33,9 @@ def cast_to_string(clause)

def cast_to_datetime(clause)
if ThinkingSphinx::Configuration.instance.use_64_bit
"cast(extract(epoch from #{clause}) as bigint)"
"cast(floor(extract(epoch from #{clause})) as bigint)"
else
"cast(extract(epoch from #{clause}) as int)"
"cast(floor(extract(epoch from #{clause})) as int)"
end
end

Expand Down

0 comments on commit 07c2c29

Please sign in to comment.