-
Notifications
You must be signed in to change notification settings - Fork 818
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
JSON Support #168
Comments
Ok, I traced it down to 'UseCast'. NHibernate is setting the NpgsqlParameter in some fashion that is turning |
I have worked around the issue with the following horrible code.
|
Hi, @drusellers ! Indeed, Npgsql needs a better way to handle type casting. I even created an issue about that: #125 . In order to add json datatype support, besides adding NpgsqlDbType, you will need to add a line to PrepareDefaultTypesMap method in NpgsqlTypesHelper:
If you want to provide a custom converter in text format and/or binary format, you can do so by specifying your custom converters when calling AddType. You may have a look at current converters like:
We can work together on this issue to add it. |
I would definitely appreciate any help you can provide on the topic. |
Sure! I'll play with it and will let you know what I get. I'll use this issue to create documentation about how to add custom types support to Npgsql. I think this will help a lot of developers who work with Npgsql. :) |
@franciscojunior what's the best way for me to help? |
Hi, @drusellers ! I'm really sorry I didn't check this issue yet. :( As things seem to be going ok now, I can work on this issue too. Give me some time while I write some documentation about how to add a custom type. I'll use json type as the example. Sorry for making you wait :( |
No worries. I have a work around. Just not sure how best to help. -d On Sat, Mar 29, 2014 at 5:29 PM, Francisco Figueiredo Jr.
|
Great! I'm glad to know I'm not giving you too much trouble :) Thanks for your comprehension. |
Hello, I have been getting the same issue "ERROR: 42804: column "x" is of type json but expression is of type text" Is this a Npgsql issue or OrmLite which is what I am using in this case. Many thanks |
I believe it to ultimately be a 'Npgsql' issue - because its trying to do a cast in the sql to 'text' when the column is 'json' - in order to get past it I had to do the following 'hack' to make it work, for more details see above.
|
I see, I'll try your hack then while a fix is put in place.. Many thanks |
@drusellers so where exactly did you put this code? |
I don't know OrmLite enough to say where - I did mine with NHibernate and put it in an |
I found the place where to put it in OrmLite and it works. I also found out you can do the same in Npgsql and "turn off" casting but the hack on the ORM is a better place I would think. Thanks for your help |
Hi, all! Sorry for taking so long. I hope to get something about it by the weekend. |
Just created a pull request which adds support for json datatype. @drusellers , you will now be able to set the NpgsqlDbType to Json. For while, the only way to get json support is to set the NpgsqlDbType. As json datatype looks just like string, Npgsql won't be able to tell the difference between a text and json if you simply set the parameter value. Regarding your changes to omit the parameter cast (which is also another possible solution) I'm working on this support too. See #146 and #125 |
I also added a wiki page which explains how to add custom datatypes to Npgsql. It is very basic at this moment, but I'll fill it with more details. Please, check it out and let me know what you think. |
👍 AWESOME On Thu, Apr 17, 2014 at 4:14 PM, Francisco Figueiredo Jr. <
|
@drusellers , we added support for json and jsonb and hstore as well. See #242 (comment) for more information. Would you mind to check latest master branch and test if it is working for you now? Thanks in advance. |
I'm going to go ahead and close this, if any issue is found with JSON support please reopen. |
👍 everything looks good |
I am currently trying to get NHibernate to work with JSON data type. I am currently getting stuck on
ERROR: 42804: column "post" is of type json but expression is of type text
- I have used Npgsql directly and it works just fine. I am thinking that step one might be to addJson
toNpgsqlDbType
but after that I am not 100% sure where to go.The text was updated successfully, but these errors were encountered: