-
Notifications
You must be signed in to change notification settings - Fork 116
#211 Add 'make_*' functions to PostgresModule #295
Conversation
|
I'll be hacking away at this again today, got side tracked with the holidays! |
b9eb8e7
to
58e2533
Compare
@robmwalsh I've finally got this working, I'm thinking it's actually using the toString version of the Interval and Timestampz case classes which might be fine for now. Let me know any thoughts you have for improving and I'll address them. I added in the postgres driver to reference the PGInterval class, which is similar to how slick implements this functionality. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice work - I don't have a problem with adding the postgres driver as I think we're going to move away from JDBC. A few more changes and this should be good to go. Let me know if you need a hand with any of it.
|
@robmwalsh this is a little bit closer to what I think we'd like ultimately. I'm wondering What you think I need to either 1) just us the toString I've defined on Timestampz and Interval or 2) have it use the tupled form of them. Also I think you were suggesting I remove the Timestampz case class, given how I've structured this do you think that still makes sense. My main motivator was that it provides a nice interface for creating them that matches the function args of the postgres function. Excited to get this a little bit closer :) |
@robmwalsh I have the question above about Timestampz and wondering if you have any ideas about how to fix my broken tests. |
@brbrown25 @jczuchnowski we now have a working dialect specific type tag for postgres :) The main issue was we were conflating type tags (which are associated with the values but are just implicit objects) with the values themselves. Thanks to @jczuchnowski for finding the cause of the compiling never ending. @brbrown25 can you please pull the latest commits? your tests are now failing again :) |
Thanks! Yeah I'll pull and look. The PGInterval should only be used when the decoding is happening but I'll get to the bottom of that! |
|
@robmwalsh @jczuchnowski I'm down to the following issues that I'm not quite sure how to address.
But I'm not quite sure where that's coming from. |
postgres/src/main/scala/zio/sql/postgresql/PostgresModule.scala
Outdated
Show resolved
Hide resolved
postgres/src/main/scala/zio/sql/postgresql/PostgresModule.scala
Outdated
Show resolved
Hide resolved
postgres/src/main/scala/zio/sql/postgresql/PostgresModule.scala
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very minor stuff now :) Please also do a final pass to make sure you remove any unneeded comments
postgres/src/main/scala/zio/sql/postgresql/PostgresModule.scala
Outdated
Show resolved
Hide resolved
postgres/src/main/scala/zio/sql/postgresql/PostgresModule.scala
Outdated
Show resolved
Hide resolved
@robmwalsh I've gone ahead and cleaned this up and squashed it down into a single commit. I really wanted to be able to do something like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, just some (hopefully) minor stuff now.
type TypeTagExtension[+A] <: Tag[A] with Decodeable[A] | ||
|
||
trait Decodeable[+A] { | ||
def decode[A, DecodingError](column: Either[Int, String], resultSet: ResultSet): Either[DecodingError, A] = ??? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using ???
is turning a possible compiler error "you need to implement def decode
" into a possible runtime error (NotImplementedError
), which we like to avoid where possible! We need to make sure every extension type is Decodable
and that is has a valid decode
implementation. If you drop the = ???
from the end, it'll let the compiler stop us making mistakes. In general, you should only ever use ???
to plug gaps temporarily; the implementation shows you why:
def ??? : Nothing = throw new NotImplementedError
Unrelated, I don't think you should be introducing new type parameters here - this is shadowing the +A
type parameter in trait Decodable[+A]
, which means it can actually return anything instead of whatever the +A
type in Decodable
is (which I think is what we actually want). Similarly DecodingError
is shadowing self.ReadExecutor.DecodingError
, which is what we actually want to return here. How you can actually access that from here could be tricky.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- drop the ???
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I agree about the not introducing new type parameters. We can talk in our pair about how to handle DecodingError
The reason I kept the A was for Timstampz to let it return a ZonedDateTime instead of a Timestampz
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
boom!
zio-archive#211 Add 'make_*' functions to PostgresModule
No description provided.