-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SORRY! This type (NQPMu) does not support associative operations (PosgreSQL) #106
Comments
This isn't a problem with DBIish per-se, but rather with what you are asking Rakudo to do here (though I would agree that the error is very far from awesome.) What is happening with code like this is that the
And the DbConn:
Which works Fine:
|
@jonathanstowe Wow, with such a serious explanation, it's a wonder it sometimes works! (And yes, it does sometimes work to define database handles at the top level in a module. I was doing the same thing with MongoDB, and somehow it works. Sometimes.) So how can this error be improved? Can rakudo catch the error at a higher level and give an error message like what you just told me? (I.e., "Top level variables are serialized at compilation time. [name] serializes as NQPMu, so try defining it at runtime in a function.") Or cut out the details: "Only simpler types are allowed as top-level variables. Could not serialize: [name]". Obviously I should file this as a feature request in Rakudo, but is that approach/solution reasonable? Because I think we must prevent people from making this mistake if people are to get a good early impression from Perl 6. |
It might work if the precompiled form can't be found. That could be the reason it sometimes works. I think it would work if you wrote |
@b2gills I realized I need a per-thread connection, so it's already become something more sophisticated. Right now I'm more interested in how to make Rakudo's error message better. This seems like it should be a high level complaint, not a low level one. By the way, this is what the DB handle init code became:
|
It seems DBIish with Pg does not work across multiple files. I've tested this on Windows 10 and Linux, using the September release of rakudo. The test case is:
Importer.pm6 contains:
DbConn.pm6 contains:
cd to the directory where you put the scripts, and run:
rm -r ./.precomp; perl6 -I. -MImporter -e 'say 5'
In my testing, an old .precomp directory sometimes prevented the various tests from failing.
When I fiddle with the code to get it to work, I often see this error instead:
The problems go away when I only use DBIish within a single script. Unfortunately, that's too clumsy to be a usable workaround.
The text was updated successfully, but these errors were encountered: