@@ -181,7 +181,12 @@ def test_datetime_arrow
181
181
end
182
182
datetime = DateTime . new ( 2025 , 7 , 20 , 20 , 40 , 23 )
183
183
User . create! ( datetime : datetime )
184
- array = Arrow ::TimestampArray . new ( :micro , [ datetime . localtime ] )
184
+ if sqlite?
185
+ unit = :nano
186
+ else
187
+ unit = :micro
188
+ end
189
+ array = Arrow ::TimestampArray . new ( unit , [ datetime . localtime ] )
185
190
assert_equal ( Arrow ::Table . new ( id : Arrow ::Int64Array . new ( [ 1 ] ) ,
186
191
datetime : array ) ,
187
192
User . to_arrow )
@@ -211,4 +216,31 @@ def test_time_arrow
211
216
time : array ) ,
212
217
User . to_arrow )
213
218
end
219
+
220
+ def test_timestamp_active_record
221
+ ActiveRecord ::Base . connection . create_table ( "users" ) do |table |
222
+ table . timestamp :timestamp
223
+ end
224
+ timestamp = Time . new ( 2025 , 7 , 20 , 20 , 40 , 23 )
225
+ User . create! ( timestamp : timestamp )
226
+ assert_equal ( User . new ( id : 1 , timestamp : timestamp ) ,
227
+ User . first )
228
+ end
229
+
230
+ def test_timestamp_arrow
231
+ ActiveRecord ::Base . connection . create_table ( "users" ) do |table |
232
+ table . timestamp :timestamp
233
+ end
234
+ timestamp = Time . new ( 2025 , 7 , 20 , 20 , 40 , 23 )
235
+ User . create! ( timestamp : timestamp )
236
+ if sqlite?
237
+ unit = :nano
238
+ else
239
+ unit = :micro
240
+ end
241
+ array = Arrow ::TimestampArray . new ( unit , [ timestamp ] )
242
+ assert_equal ( Arrow ::Table . new ( id : Arrow ::Int64Array . new ( [ 1 ] ) ,
243
+ timestamp : array ) ,
244
+ User . to_arrow )
245
+ end
214
246
end
0 commit comments