Skip to content

Conversation

kshvakov
Copy link
Contributor

@kshvakov kshvakov commented Feb 4, 2022

No description provided.

Copy link
Member

@dhui dhui left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

Any idea why golangci-lint is failing?

query := "INSERT INTO " + ch.config.MigrationsTable + " (version, dirty, sequence) VALUES (?, ?, ?)"
if _, err := tx.Exec(query, version, bool(dirty), time.Now().UnixNano()); err != nil {
query := "INSERT INTO " + ch.config.MigrationsTable + " (version, dirty, sequence) VALUES"
batch, err := tx.Prepare(query)
Copy link
Member

Choose a reason for hiding this comment

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

Why does prepare need to be used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since V2 supports insert request only in "prepared statements" or in asynchronous mode

Choose a reason for hiding this comment

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

Using numeric placeholders or named placeholder is also supported. Just FI.

"net/url"
"testing"

_ "github.com/ClickHouse/clickhouse-go/v2"
Copy link
Member

Choose a reason for hiding this comment

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

Are the tests split to support both v1 and v2? What's involved in supporting both versions and why would we not update to v2 and drop support for v2? I'm not a fan of duplicate code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

some people use golang-migrate as part of their application. Go driver V1 and V2 are not compatible and it will be impossible to import them in the same application

Copy link
Member

Choose a reason for hiding this comment

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

@kshvakov I like the idea to support both for a limited time, on the other hand, for the CLI, we can only support one, so we have to decide if that should be v1 or v2.

@@ -80,6 +80,11 @@ func (ch *ClickHouse) Open(dsn string) (database.Driver, error) {
return nil, err
}

database := purl.Query().Get("database")
if db := strings.TrimPrefix(purl.Path, "/"); len(database) == 0 && len(db) != 0 {
Copy link
Member

Choose a reason for hiding this comment

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

Remove this. It's more confusing if there are 2 ways to specify the same thing. e.g. if the values differ, which one should take precedence?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is necessary for compatibility with both DSN formats in V1 and V2

@kshvakov
Copy link
Contributor Author

kshvakov commented Feb 7, 2022

I can remove V1 support, maybe it will even be better for new users

@sergey-telpuk
Copy link

hello, it was fixed in #707

@makeavish
Copy link

Someone please merge this PR

@makeavish
Copy link

@sergey-telpuk #707 was not merged so can't say that it was fixed. Maybe you forgot to merge.
Please merge the PR so that we can use it.

@sergey-telpuk
Copy link

@sergey-telpuk #707 was not merged so can't say that it was fixed. Maybe you forgot to merge. Please merge the PR so that we can use it.

yes, I'm waiting for the approval PR

@vincentbernat
Copy link

I did miss this PR and did something similar to you, except I didn't keep support for v1. Your change looks good for me and includes almost all my changes. I have just added some backquotes around table and database names, but I suppose people should not try the devil, so no need to update. I did use named place holders instead of preparing a request, but your solution is good too.

Tested on Go 1.18.

@Fontinalis Fontinalis added the database Updates database drivers label Apr 27, 2022
@Fontinalis Fontinalis added this to the v4.16.0 milestone Apr 27, 2022
@Fontinalis
Copy link
Member

I can remove V1 support, maybe it will even be better for new users

If you remove V1 support and resolve the conflicts, I'm more than happy to give it a look and merge it within days. 👍🏻

@makeavish
Copy link

@kshvakov Please remove V1 support and resolve conflicts so that this can be reviewed and merged.

@vincentbernat
Copy link

It seems that #723 is a PR without V1.

@tjsampson
Copy link

Any update on getting this merged?

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

Successfully merging this pull request may close these issues.

7 participants