我使用Goldilocks数据库似乎是Oracle。
我在数据库上有一条记录。
gSQL> desc POSTS
COLUMN_NAME TYPE IS_NULLABLE
-------------- ------------------------------ -----------
NU NUMBER TRUE
NAME CHARACTER VARYING(4000) TRUE
DATE_TEST DATE TRUE
TIMESTAMP_TEST TIMESTAMP(6) WITHOUT TIME ZONE TRUE
CREATED_AT TIMESTAMP(6) WITHOUT TIME ZONE TRUE
UPDATED_AT TIMESTAMP(6) WITHOUT TIME ZONE TRUE
gSQL> SELECT NU, NAME, DATE_TEST, TIMESTAMP_TEST FROM POSTS;
NU NAME DATE_TEST TIMESTAMP_TEST
-- ---- ------------------- --------------------------
4 qwe 2018-03-14 00:00:00 2018-03-23 00:59:00.000000
1 row selected.
当我将记录放在rails上的ruby服务器控制台上时,我只获得NULL与时间相关的变量。
这是源码和控制台。
@posts.each do |post|
if (post.nu == nil) then
puts '[null] "' + post.nu + '"'
else
puts post.nu.to_s
end
if (post.name == nil) then
puts '[null] "' + post.name + '"'
else
puts post.name.to_s
end
if (post.date_test == nil) then
puts '[null] "' + post.date_test.to_s + '"'
else
puts post.date_test.to_s
end
if (post.timestamp_test == nil) then
puts '[null] "' + post.timestamp_test.to_s + '"'
else
puts post.timestatmp_test.to_s
end
puts '[API TIME] ' + Time.now.to_s
end
服务器输出
Started GET "/posts" for 192.168.0.40 at 2018-03-08 14:53:28 +0900
Processing by PostsController#index as HTML
Post Load (6.8ms) SELECT posts.* FROM posts
4
qwe
[null] ""
[null] ""
[API TIME] 2018-03-08 15:02:07 +0900
Rendering posts/index.html.erb within layouts/application
我该怎么办?