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

automap function on SelectBuilder object does not work #1

Closed
adam-mahmood opened this issue Sep 19, 2017 · 6 comments
Closed

automap function on SelectBuilder object does not work #1

adam-mahmood opened this issue Sep 19, 2017 · 6 comments

Comments

@adam-mahmood
Copy link

adam-mahmood commented Sep 19, 2017

db.select( "SELECT RecIndex,Site FROM dbo.MEAS_CARRIER where Time >= ? ORDER BY RecIndex ASC") .parameterStream(Flowable.just(Instant.now().minus(Duration.ofHours(1).plus(Duration.ofMinutes(2))))
.delay(1, TimeUnit.SECONDS).repeat())
.autoMap(CarrierMeasuremnt.class).distinct();

Your automap function returns a Flowable, and when you subscribe to the Flowable the value is null!

Can you please help?

@davidmoten
Copy link
Owner

Thanks for the report, I'll have a look.

@davidmoten
Copy link
Owner

I think the problem is that the automapped object returns null from the toString method so you think you have a null object but you don't. Here's a runnable example using the Database.test() method:

Database.test() //
    .select("select score from person where name=?") //
    .parameterStream(Flowable.just("FRED")) //
    .autoMap(Score.class) //
    .doOnNext(System.out::println) //
    .doOnNext(x -> System.out.println(x.score())) //
    .blockingSubscribe();

interface Score {
    @Column
    int score();
}

The output is:

null
21

The behaviour is definitely confusing so I'll make a change to generate a meaningful message from the automapped object's toString method.

@davidmoten
Copy link
Owner

I've deployed 0.1-RC2 to Maven Central with the toString method enhancement. Let me know if your issue is solved now.

@adam-mahmood
Copy link
Author

Thank you David. I believe that has fixed the issue, however i will test at work tomorrow morning.
I must say you have done a brilliant job in creating this library.

@davidmoten
Copy link
Owner

Glad you like it @adam-mahmood. By the way use 0.1-RC3 to pick up another fix. Cheers.

@davidmoten
Copy link
Owner

Closing this because conversation is continuing in #3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants