7
7
class FinderTest < TestCase
8
8
fixtures :posts
9
9
10
- # def test_find
11
- # assert_equal(posts(:first).title, Post.find(1).title)
12
- # end
13
-
10
+ def test_find
11
+ assert_equal ( posts ( :first ) . title , Post . find ( 1 ) . title )
12
+ end
13
+
14
14
def skip_test_bigint
15
- # 多分だけど、DuckDBで返ってきたIDの値が、見た目上はInteger型だけど、実際は違う??どっかでCastしないといけない??
15
+ # TODO: 多分だけど、DuckDBで返ってきたIDの値が、見た目上はInteger型だけど、実際は違う??どっかでCastしないといけない??
16
16
# Primary KeyをBigIntにすると、in_order_ofで、うまく結果が返ってこない。これは、多分IntとBigIntが違うからだと思う。
17
17
18
18
records = Post . where ( enabled : true ) . where ( id : [ 1 , 2 ] ) . records
@@ -28,33 +28,22 @@ def skip_test_bigint
28
28
p [ 1 , 2 ] . map { |v | v . class . ancestors }
29
29
end
30
30
31
- # def test_find_where
32
- # records = Post.where(enabled: true).find([2, 1, 3])
33
- # assert_equal 3, records.size
34
- # assert_equal posts(:second).title, records[0].title
35
- # assert_equal posts(:first).title, records[1].title
36
- # assert_equal posts(:third).title, records[2].title
37
- # end
38
-
39
- def failur_test_find_with_ids_with_limit_and_order_clause
40
- # TODO: order, where を使った時に順番がずれる
41
- p records = Post . limit ( 2 ) . order ( :id ) . where ( id : [ 5 , 3 , 1 ] ) . records
42
-
43
- records = Post . limit ( 2 ) . order ( :id ) . find ( [ 5 , 3 , 1 ] )
44
- p records
45
- assert_equal 2 , records . size
46
- assert_equal posts ( :first ) . title , records [ 0 ] . title
47
- assert_equal posts ( :third ) . title , records [ 1 ] . title
31
+ def test_find_where
32
+ records = Post . where ( enabled : true ) . find ( [ 2 , 1 , 3 ] )
33
+ assert_equal 3 , records . size
34
+ assert_equal posts ( :second ) . title , records [ 0 ] . title
35
+ assert_equal posts ( :first ) . title , records [ 1 ] . title
36
+ assert_equal posts ( :third ) . title , records [ 2 ] . title
48
37
end
49
38
50
- # def test_exists
51
- # assert_equal true, Post.exists?(1)
52
- # assert_equal true, Post.exists?("1")
53
- # assert_equal true, Post.exists?(title: Post.find(1).title)
54
- # assert_equal true, Post.exists?(id: [1, 9999])
39
+ def test_exists
40
+ assert_equal true , Post . exists? ( 1 )
41
+ assert_equal true , Post . exists? ( "1" )
42
+ assert_equal true , Post . exists? ( title : Post . find ( 1 ) . title )
43
+ assert_equal true , Post . exists? ( id : [ 1 , 9999 ] )
55
44
56
- # assert_equal false, Post.exists?(45)
57
- # assert_equal false, Post.exists?(9999999999999999999999999999999)
58
- # assert_equal false, Post.exists?(Post.new.id)
59
- # end
45
+ assert_equal false , Post . exists? ( 45 )
46
+ assert_equal false , Post . exists? ( 9999999999999999999999999999999 )
47
+ assert_equal false , Post . exists? ( Post . new . id )
48
+ end
60
49
end
0 commit comments