@@ -122,4 +122,36 @@ defmodule Localize.EctoTest do
122122 Localize . put_locale ( "en" )
123123 end
124124 end
125+
126+ describe "current-locale arities of the query helpers" do
127+ test "lower/1, upper/1 and initcap/1 use the current locale's collation" do
128+ { :ok , _ } = Localize . put_locale ( "tr" )
129+
130+ lower_query = from p in "products" , select: lower ( p . name )
131+ upper_query = from p in "products" , select: upper ( p . name )
132+ initcap_query = from p in "products" , select: initcap ( p . name )
133+
134+ assert to_sql ( lower_query ) =~ ~s[ lower(p0."name" COLLATE "tr-x-icu")]
135+ assert to_sql ( upper_query ) =~ ~s[ upper(p0."name" COLLATE "tr-x-icu")]
136+ assert to_sql ( initcap_query ) =~ ~s[ initcap(p0."name" COLLATE "tr-x-icu")]
137+ after
138+ Localize . put_locale ( "en" )
139+ end
140+
141+ test "ts_match/2 resolves the configuration from the current locale" do
142+ { :ok , _ } = Localize . put_locale ( "de" )
143+ query = from p in "products" , where: ts_match ( p . name , "stuhl" ) , select: p . name
144+
145+ assert to_sql ( query ) =~ "to_tsvector"
146+ after
147+ Localize . put_locale ( "en" )
148+ end
149+
150+ test "a pinned zone is accepted by at_time_zone/2" do
151+ zone = "ausyd"
152+ query = from p in "products" , select: at_time_zone ( p . inserted_at , ^ zone )
153+
154+ assert to_sql ( query ) =~ "AT TIME ZONE"
155+ end
156+ end
125157end
0 commit comments