-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Model query hangs indefinitely with Postgres numeric[] columns #16
Comments
will take a look today |
@z64 it looks really strange. I've added several tests to match exact requirment and run all test suite with |
Sure. A disclaimer, I've cleaned the verbose-ness of this a bit but haven't pushed the code yet (learning how to use this lib and PG at the same time! 😄 ) but this is basically what I'm working with: Model: https://github.com/z64/traikoa/blob/master/src/traikoa/database/system.cr Migration (again, mind my playing / learning, though maybe that's an issue): https://github.com/z64/traikoa/blob/master/src/traikoa/database/migrations/20170618001337825_system.cr Config (it's default, from the README basically): https://github.com/z64/traikoa/blob/master/database_example.yml Not the exact code I'm using, but close, and maybe something will jump out at you in the meantime until I get home later.. I'm using 0.23. |
actually it is strange that you even have opportunity to run any code with jennifer using 0.23 crystal 😄 - they've changed macros inheritance strategy so you should get |
Perhaps 0.22 then haha. again not at my home PC to check :( And okay. I'll try to do some more digging later.. 😓 I'll also perhaps try running the current spec suite myself. I think that might be easier for me. |
hi @z64 . Finally we get crystal 0.23.1 so we could continue on this one. Do you have any progress on this one? |
Hey @imdrasil . The last time I worked on this I was trying to just run your existing specs for (this is with 0.22 with pg adapter) I had set Haven't had a moment to revisit it since, but if you have any ideas, the exception isn't very telling to me as to what might be wrong. Also - good idea moving the README docs into the wiki! 👍 |
@z64 it seems like you've missed password or user anyway - I've reproduced this removing setting them. Also values could be wrong or use has no rights to operate with this table. Please check it again and try to open psql with your creds. |
@z64 any updates on this one? |
Hey there! Sorry for the long delay 😞 I've managed to run the specs after some fiddling with permissions on the postgres side that weren't right. It almost seemed like it was going to be related to #23 , as that's exactly what it does ; "freezes"
That done, I'm unsure what else to look at. The schema & model I'm currently working with: https://gist.github.com/z64/872ebab2293838cb627367a7a24bd236 And freezing with anything like: StarSystem.where { _name == "Test" }.to_a I've also tried the |
So, I took a step back and tried to reproduce the issue using only require "pg"
puts "Opening connection"
PG_DB = PG.connect("postgres://traikoa:traikoa@localhost")
puts "Creating table"
PG_DB.exec <<-SQL
CREATE TABLE IF NOT EXISTS array_test (
position numeric[]
);
SQL
puts "Inserting values"
PG_DB.exec <<-SQL
INSERT INTO array_test (position) VALUES ('{0.1, 0.2, 0.3}');
SQL
puts "Running query"
PG_DB.query_one("select position from array_test") do |rs|
puts rs
puts rs.read(Array(Float64))
end
puts "Cleaning up"
PG_DB.exec <<-SQL
DROP TABLE array_test;
SQL
puts "Closing connection"
PG_DB.close Hangs indefinitely. It would seem to be an issue with coercing Seems I should take this issue to |
@z64 try it with |
@z64 Did you try it? |
I believe I did, and this threw other exceptions. Don't have access to them right this moment. It seems like the supported array decoded types are defined here: {% for type in %w(Bool Char Int16 Int32 String Int64 Float32 Float64) %}
def self.decode_array_element(io, t : {{type.id}}.class, dim_info) https://github.com/will/crystal-pg/blob/master/src/pg/decoders/array_decoder.cr#L69 And later: array_type 1000, Bool
array_type 1002, Char
array_type 1005, Int16
array_type 1007, Int32
array_type 1009, String
array_type 1016, Int64
array_type 1021, Float32
array_type 1022, Float64 https://github.com/will/crystal-pg/blob/master/src/pg/decoders/array_decoder.cr#L114-L121 which does not have I did open an issue too; will/crystal-pg#105 |
@z64 hm, what do u think what we should do with this one here? There is no activity in the driver repo so I'm not sure fix for this will arrive soon. |
Your call. Workarounds exist using |
At the least, the issue is here and on the driver in case anyone runs into the same problem 😅 |
I'm thinking what we should do with this - close it or leave opened. As for me this one is a missing funtionality from the pg driver and I can't do with this here nothing. |
Hi there!
I've defined a model, and am simply trying to pull a full instance of it:
pp StarSystem.all.first!
However, this hangs forever with:
This however works fine:
pp StarSystem.all.count
This works too:
I resolved this issue at one point, but I can't remember how I did it :( According to the specs, this should work fine..
The postgres access logs look normal. I'm unsure, but it looks like it isn't actually running the query.
Something I'm missing?
The text was updated successfully, but these errors were encountered: