diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a3c147..ae97563 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +### 0.6.0 + +* Adding support for Microsoft SQL Server + ### 0.5.0 * Adding ```order_by_rand``` and ```order_by_rand_weighted``` scopes @@ -14,4 +18,4 @@ ### 0.3.0 * Added random_weighted() (thanks mceachen) -* Added random_by_id_shuffle() to fix issue with uniq in postgres and provide some options \ No newline at end of file +* Added random_by_id_shuffle() to fix issue with uniq in postgres and provide some options diff --git a/lib/randumb/syntax.rb b/lib/randumb/syntax.rb index 04ddd69..36ac297 100644 --- a/lib/randumb/syntax.rb +++ b/lib/randumb/syntax.rb @@ -31,6 +31,8 @@ def random_for(opts) random_for_sqlite(opts) elsif adapter_name =~ /(postgres|postgis)/i random_for_postgres(opts) + elsif adapter_name =~ /mssql/i + random_for_mssql(opts) elsif adapter_name =~ /mysql/i random_for_mysql(opts) else @@ -69,6 +71,10 @@ def random_for_postgres(opts) "RANDOM()" end + def random_for_mssql(opts) + "NEWID()" + end + def random_for_mysql(opts) if seed = opts[:seed] "RAND(#{seed.to_i})" diff --git a/lib/randumb/version.rb b/lib/randumb/version.rb index dc5fe22..1b46434 100644 --- a/lib/randumb/version.rb +++ b/lib/randumb/version.rb @@ -1,3 +1,3 @@ module Randumb - VERSION = "0.5.0" + VERSION = "0.6.0" end