Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: Implement joins with golang templates#6429

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Emyrk merged 43 commits intomainfromstevenmasley/build_with_template
Mar 10, 2023

Conversation

Emyrk
Copy link
Member

@EmyrkEmyrk commentedMar 2, 2023
edited
Loading

Golang template alternative to#6371

What this does

This adds database joins and dynamic SQL queries. I only did this for workspace builds in this PR. Read the other PR and this issue:#6426.

Fixes:#6426

Next work

I will use templates for authorized queries next, remove the strings replace.

@EmyrkEmyrk marked this pull request as ready for reviewMarch 8, 2023 15:22
// "$1, $2" instead of "$1, $1".
// 2. SQLx does not handle uuid arrays.
// 3. SQLx only supports ":name" style arguments and breaks "::" type casting.
func bindNamed(query string, arg interface{}) (newQuery string, args []interface{}, err error) {
Copy link
Member

Choose a reason for hiding this comment

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

Is there no other way around this? I really dislike the regexp rewriting and reflection on every single query.

Is sqlx not smarter than this?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Actually SQLx is a bit dummber. I took this code implementation from SQLx and changed some things. The usage for SQLx issqlx.Named(). But it doesn't handle things that I put in the function comments, so I adjusted it.

https://github.com/jmoiron/sqlx/blob/master/named.go#LL421-L436C2

Instead of a regex, they wrote a more proper parser:https://github.com/jmoiron/sqlx/blob/master/named.go#L331

But the parser doesn't work. It parses comments and they use:arg as arguments, so when we typecast with::, it's seen as escaping a colon literal. So our sql queries would have to do::::.

The SQLx parser is honestly really dumb with actual SQL.

Copy link
Member

@johnstcnjohnstcn left a comment

Choose a reason for hiding this comment

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

Looks fine to me except forloadQueries, this should happen as close to startup as possible.

@EmyrkEmyrk merged commit8b125d6 intomainMar 10, 2023
@EmyrkEmyrk deleted the stevenmasley/build_with_template branchMarch 10, 2023 15:44
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsMar 10, 2023
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@johnstcnjohnstcnjohnstcn approved these changes

@deansheatherdeansheatherdeansheather approved these changes

@kylecarbskylecarbsAwaiting requested review from kylecarbs

Assignees

@EmyrkEmyrk

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Discussion: How should we handle joins?
3 participants
@Emyrk@johnstcn@deansheather

[8]ページ先頭

©2009-2025 Movatter.jp