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

feat: Implement pgx support #76

Merged
merged 28 commits into from
Aug 20, 2023
Merged

feat: Implement pgx support #76

merged 28 commits into from
Aug 20, 2023

Conversation

hound672
Copy link
Contributor

@hound672 hound672 commented Aug 14, 2023

Hello.
The frist attempt to implement pgx support.
For now there is no any unittests, example is weird and so on.
I just wonder if I am on the right way.

docker-compose.yml Outdated Show resolved Hide resolved
Copy link
Member

@maranqz maranqz left a comment

Choose a reason for hiding this comment

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

You are on the right way)

pgx/contract.go Outdated Show resolved Hide resolved
pgx/factory.go Outdated Show resolved Hide resolved
pgx/savepoint.go Outdated Show resolved Hide resolved
pgx/contract.go Outdated Show resolved Hide resolved
@hound672
Copy link
Contributor Author

hound672 commented Aug 14, 2023

remove main.go, docker-compose.
write unittests for transaction and for settings.


sqlmock cannot be used here due to different interfaces so I used pgxmock lib

@maranqz
Copy link
Member

maranqz commented Aug 15, 2023

I'll take a closer look at the weekend.

Copy link
Member

@maranqz maranqz left a comment

Choose a reason for hiding this comment

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

Add information about the pgx adapter in README.md and CHANGELOG.md

@hound672
Copy link
Contributor Author

Looks like pgxmock does not work on go1.13.
I had the same issues with go1.13.

@maranqz
Copy link
Member

maranqz commented Aug 15, 2023

If it's true, mark it in README.md and add skip test for old version of Go. GORM adapterfor example.

@hound672
Copy link
Contributor Author

If it's true, mark it in README.md and add skip test for old version of Go. GORM adapterfor example.

Ok, I'll try.
So this an another reason why I think that separated repositories is a good option.

@hound672 hound672 changed the title feat: Implement pgx support (1 take) feat: Implement pgx support Aug 15, 2023
@maranqz
Copy link
Member

maranqz commented Aug 19, 2023

  1. I see in pgx repo This is the previous stable v4 release. v5 been released.
    Is v4 still actual?
    https://github.com/jackc/pgx/tree/v4.18.1

  2. Let's call the adapter pgx v4 to show the version explicitly.

pgx/example_test.go Outdated Show resolved Hide resolved
pgx/example_test.go Outdated Show resolved Hide resolved
pgx/context.go Outdated Show resolved Hide resolved
pgx/contract.go Outdated Show resolved Hide resolved
pgx/contract.go Outdated Show resolved Hide resolved
pgx/transaction.go Outdated Show resolved Hide resolved
@hound672
Copy link
Contributor Author

hound672 commented Aug 19, 2023

  1. I see in pgx repo This is the previous stable v4 release. v5 been released.
    Is v4 still actual?
    https://github.com/jackc/pgx/tree/v4.18.1
  2. Let's call the adapter pgx v4 to show the version explicitly.

In the package's name? Like pgx -> pgx_v4?

@maranqz
Copy link
Member

maranqz commented Aug 19, 2023

Linter: I checked with 1.49 linter version and there are no any issues.
And I will not modify files in trmanager.

I'm fixing it)

@hound672
Copy link
Contributor Author

Linter: I checked with 1.49 linter version and there are no any issues.
And I will not modify files in trmanager.

I'm fixing it)

It's pretty strange) what's wrong?)

@maranqz
Copy link
Member

maranqz commented Aug 19, 2023

golangci-lint version is 1.56, I think something changed in it.

I excluded mock dirs.

@hound672
Copy link
Contributor Author

golangci-lint version is 1.56, I think something changed in it.

I excluded mock dirs.

I see, excluding. But why does it work before these changes?

@maranqz
Copy link
Member

maranqz commented Aug 19, 2023

I think, cause is updating of exhaustruct: from 2.3.0 to 3.1.0
https://github.com/golangci/golangci-lint/blob/master/CHANGELOG.md#v1540

@hound672
Copy link
Contributor Author

Pgx v5 works only with 1.19 and higher (due to generics). But in example should be two flags:

  1. Works only with real db
  2. Build only with 1.19 and higher.

@maranqz
Copy link
Member

maranqz commented Aug 19, 2023

Build only with 1.19 and higher.

Use for pgxv5

//go:build go1.19,with_real_db
// +build go1.19,with_real_db
Space-separated elements // +build pro enterprise pro OR enterprise
Comma-separated elements // +build pro,enterprise pro AND enterprise
Exclamation point elements // +build !pro NOT pro

@hound672
Copy link
Contributor Author

done.
Actions passed after changes (in my env).

@coveralls
Copy link
Collaborator

coveralls commented Aug 19, 2023

Pull Request Test Coverage Report for Build 5915867691

  • 221 of 239 (92.47%) changed or added relevant lines in 8 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.3%) to 94.015%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pgxv4/settings.go 39 42 92.86%
pgxv5/settings.go 40 43 93.02%
pgxv4/context.go 12 18 66.67%
pgxv5/context.go 12 18 66.67%
Totals Coverage Status
Change from base Build 5857614173: -0.3%
Covered Lines: 1461
Relevant Lines: 1554

💛 - Coveralls

pgxv4/settings.go Outdated Show resolved Hide resolved
@maranqz
Copy link
Member

maranqz commented Aug 20, 2023

Do you want to fix something else in the PR?
I think PR is ready to merge.
Good job and thank you for your work👍🎉🚀.

maranqz
maranqz previously approved these changes Aug 20, 2023
@hound672
Copy link
Contributor Author

Do you want to fix something else in the PR? I think PR is ready to merge. Good job and thank you for your work👍🎉🚀.

Thanks!)
Could you merge? Since I'm not authorized for that

@maranqz
Copy link
Member

maranqz commented Aug 20, 2023

I will bump version of the lib in first September weekend.

@maranqz maranqz merged commit ba3f75c into avito-tech:main Aug 20, 2023
8 checks passed
@maranqz maranqz mentioned this pull request Aug 20, 2023
@hound672 hound672 deleted the feat/pgx branch August 20, 2023 09:39
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.

3 participants