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

Support for AWS Keyspaces #579

Closed
wants to merge 5 commits into from

Conversation

florentsolt
Copy link
Contributor

AWS Keyspaces does not support TRUNCATE, so DELETE will do the trick.
Also, on the official docs they ask to disable initial host lookup:
https://docs.aws.amazon.com/keyspaces/latest/devguide/using_go_driver.html

Also, I had to upgrade the version of gocql, because the consistency was not properly handled in that version.

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!

@@ -155,6 +155,10 @@ func (c *Cassandra) Open(url string) (database.Driver, error) {
}
}

if s := u.Query().Get("disable-host-lookup"); len(s) > 0 {
Copy link
Member

Choose a reason for hiding this comment

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

Use ParseBool and handle the error properly

if previous != database.NilVersion {
// DELETE instead of TRUNCATE because AWS Keyspaces does not support it
// see: https://docs.aws.amazon.com/keyspaces/latest/devguide/cassandra-apis.html
query := `DELETE FROM "` + c.config.MigrationsTable + `" WHERE version = ?`
Copy link
Member

Choose a reason for hiding this comment

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

This only removes the previous version and not all versions. Having multiple versions will cause issues since selecting the current versions only selects one version without any ordering.

We can either:

  1. Delete all rows and keep the current behavior
  2. Update Version() to select the latest version
  3. ??? - Other backwards compatible suggestions?

Copy link
Member

Choose a reason for hiding this comment

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

I believe this causing the tests to fail. You can test locally by running go test -v ./database/cassandra. You'll need docker installed.

@Fontinalis Fontinalis added the source Updates source drivers label Aug 23, 2021
@Baumanar
Copy link
Contributor

Hello @florentsolt @dhui, I am currently also running into this issue, are there any news on fixing this issue anytime soon ?

@@ -156,6 +156,12 @@ func (c *Cassandra) Open(url string) (database.Driver, error) {
}
}

if flag, err := strconv.ParseBool(u.Query().Get("disable-host-lookup")); err != nil && flag {
Copy link
Contributor

Choose a reason for hiding this comment

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

Tests are failing here because it is unable to parse "" when nothing is provided. Instead it should be:

	if len(u.Query().Get("disable-host-lookup")) > 0 {
		if flag, err := strconv.ParseBool(u.Query().Get("disable-host-lookup")); err != nil && flag {
			cluster.DisableInitialHostLookup = true
		} else if err != nil {
			return nil, err
		}
	}

@dhui
Copy link
Member

dhui commented Oct 14, 2021

Thanks @florentsolt for the original PR! Due to inactivity, I'm closing this PR in favor of #634.

@dhui dhui closed this Oct 14, 2021
Baumanar pushed a commit to Baumanar/migrate that referenced this pull request Oct 14, 2021
Baumanar pushed a commit to Baumanar/migrate that referenced this pull request Oct 14, 2021
FPiety0521 pushed a commit to FPiety0521/Golang-SQL that referenced this pull request May 24, 2023
FPiety0521 pushed a commit to FPiety0521/Golang-SQL that referenced this pull request May 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
source Updates source drivers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants