Skip to content

fix: pgdialect range #1221

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

thecampagnards
Copy link
Contributor

Hello,
I suggest a fixes on pgdialect.Range, on a pg14.
Doc: https://www.postgresql.org/docs/current/rangetypes.html
Thx !

@thecampagnards thecampagnards force-pushed the master branch 3 times, most recently from 23c9808 to e50737c Compare June 19, 2025 17:06
return Array(m).Scan(anySrc)
}

func (m MultiRange[T]) AppendQuery(fmt schema.Formatter, buf []byte) ([]byte, error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should I move this logic to not have quote for Range inside array ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to specifically test which form PostgreSQL can accept, as this is a complex and uncommon case.

RangeBoundInclusiveRight RangeBound = ']'
RangeBoundExclusiveLeft RangeBound = '('
RangeBoundExclusiveRight RangeBound = ')'
RangeLowerBoundInclusive RangeLowerBound = '['
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really have to rename these variable?
The original name may not be perfect, but changing it would break backward compatibility.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can keep the same name, but I think it's preferable to keep a different type between lower and upper bound

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good I rb to the previous naming


if len(src) == 0 {
return io.ErrUnexpectedEOF
src, err = scanElem(&r.Upper, src)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to consider a comma here? I’m not sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I improved the tests with equality, I also switch to a driver.valuer so we don't need to remove '

@j2gg0s
Copy link
Collaborator

j2gg0s commented Jun 25, 2025

Thank you for your contribution, especially the related test cases.

@thecampagnards
Copy link
Contributor Author

Thank you for your contribution, especially the related test cases.

Thx for your feedbacks ! With this new updates this should be better for multirange

@thecampagnards
Copy link
Contributor Author

there is also infinity bounds, how can we handle it ? Maybe we can have Range.Lower and Range.Upper as a pointer of T and when it's nil, it's infinity ?

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

Successfully merging this pull request may close these issues.

2 participants