sqlx icon indicating copy to clipboard operation
sqlx copied to clipboard

feat(cube): support postgres cube

Open jayy-lmao opened this issue 10 months ago • 7 comments

I work on a sqlx codegen tool, and had an issue posted about the lack of support for the 'cube' extension type (https://www.postgresql.org/docs/current/cube.html).

https://github.com/jayy-lmao/sql-gen/issues/9

I could not see any outstanding issues / PRs involving Cube, so can create an issue first if necessary for discussion. Not particularly attached to how to structure the struct, serialisation, or deserialisation - ultimately just want to be able to support it for my sql-gen tool so that @yellowHatpro can carry on with using it for their project.

jayy-lmao avatar Apr 09 '24 09:04 jayy-lmao

Sorry for the build jobs -- running locally the encoding seems to be fine. Haven't been able to replicate locally with amd64 platform, alpine etc. Still figuring out why the encoding is different.

Update: have been able to reproduce by using

    let row = s.try_next().await?.unwrap();
    let rec = row.try_get::<PgCube, _>(0)?;

Locally to test. Will continue to investigate.

jayy-lmao avatar Apr 09 '24 12:04 jayy-lmao

Have handled the text case, tests now passing ☺️

jayy-lmao avatar Apr 12 '24 00:04 jayy-lmao

Have made the changes to vector indexing :)

jayy-lmao avatar Apr 21 '24 23:04 jayy-lmao

Have made changes

  • trimming the input string to make it more flexible for the spec & for user input
  • allow for _cube array type (And included a test for it)
  • remove TryFrom behaviour for &[u8], using direct function instead
  • avoid double creating a buffer, but just writing directly to the PgArgumentBuffer

jayy-lmao avatar Apr 24 '24 23:04 jayy-lmao

Apologies, I've been away for a little - I've addressed all comments but if there's any other changes that are wanted let me know

jayy-lmao avatar May 15 '24 07:05 jayy-lmao

Note that I only today realized that main has been broken for the past few weeks and I'm still working on fixing Clippy warnings (turned into errors by CI) from that.

Don't worry about fixing errors in code you didn't touch.

abonander avatar Jun 06 '24 08:06 abonander

Note that I only today realized that main has been broken for the past few weeks and I'm still working on fixing Clippy warnings (turned into errors by CI) from that.

Don't worry about fixing errors in code you didn't touch.

Just saw this then.

Oh well, at least I've resolved the changes in Encode implementation. Glad it supports returning errors now ☺️

Let me know if I can be any help with the errors.

jayy-lmao avatar Jun 06 '24 08:06 jayy-lmao

@abonander have rebased onto main now that builds are passing, and updated to address new linting rules 👍

jayy-lmao avatar Jul 09 '24 12:07 jayy-lmao