Skip to content
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

Wrong decode mechanism when using custom AbstractCodec based on field type #35

Open
cschockaert opened this issue May 16, 2021 · 4 comments
Labels
bug Something isn't working
Milestone

Comments

@cschockaert
Copy link

since you always decode an object with the target Object.class type, io.r2dbc.postgresql.codec.AbstractCodec doesn't work anymore with extra registred codec based on this implementation since io.r2dbc.postgresql.codec.AbstractCodec#canDecode is based on field type and you always pass Object.class type.

@cschockaert
Copy link
Author

cschockaert commented May 16, 2021

Was working fine in 0.2.0 version of your lib. I don't know with you dont pass anymore the field type but Object.class when you row.get ?

@gofabian
Copy link
Owner

Thanks for your report. Could you please provide a code sample that demonstrates the issue?

I don't know with you dont pass anymore the field type but Object.class when you row.get ?

I cannot remember. We had some issues in data conversion. But maybe this was an unnecessary change.

@gofabian gofabian added the bug Something isn't working label May 16, 2021
@gofabian gofabian added this to the 0.3.1 milestone May 16, 2021
@cschockaert
Copy link
Author

cschockaert commented May 16, 2021

Well a bit difficult to reproduce it fast, but it's linked to the fact that when we create a new domain extension with jooq we only need to register a org.jooq.Converter.
In reactive jooq, we need to register both a converter and a io.r2dbc.postgresql.extension.CodecRegistrar + AbstractCodec implements Extension too otherwise when inserting a record we got an exception due to the fact that the codec is not existing for the NEWTYPE.
In blocking jooq, codec is not necessary eg:

public final TableField<ReceiptInvoiceAddressRecord, Locale> COUNTRY = createField(DSL.name("country"), org.jooq.impl.SQLDataType.VARCHAR(10).nullable(false), this, "", new CountryConverter());

in blocking jooq CountryConverter is enough
in reactive jooq (with your lib) i have to add this code:
public final class LocaleCodec extends AbstractCodec implements Extension {
+
public class LocaleCodecRegistrar implements CodecRegistrar {
registering this new codec

and a META-INF/services io.r2dbc.postgresql.codec.LocaleCodecRegistrar

Seems that ReactiveJooq don't work OOTB with extras org.jooq.Converter

@cschockaert
Copy link
Author

cschockaert commented May 16, 2021

In fact, i got a workaround for my case, i registered my codec FIRST and since it was handling Object.class types (+ other types) , he was overriding behaviour for decoding basic string.

To solve my case, i just registered my codec in latest position

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants