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

Add support for clickhouse settings in NamedExec's fixBounds #948

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

Conversation

stephennancekivell
Copy link

Hi folks, im having trouble with bulk inserts into clickhouse. NamedExec queries are only getting the first value in the array.

This PR fixes the issue by extending the regex to support settings.

Eg this test case fails, with only joe getting inserted, not sally.

func TestInsertNamedBulk(t *testing.T) {
	_, err := db.Exec(schema)
	assert.NoError(t, err)
	defer cleanup(t)

	// Insert data
	_, err = db.NamedExec(
		`insert into users (id, name, age)
		SETTINGS async_insert=1, wait_for_async_insert=1
		values
		(:id, :name, :age)`,
		[]map[string]any{
			{
				"id":   1,
				"name": "joe",
				"age":  30,
			},
			{
				"id":   2,
				"name": "sally",
				"age":  31,
			},
		})
	assert.NoError(t, err)

	users, err := findUsers()
	assert.NoError(t, err)
	assert.Equal(t, []User{
		{ID: 1, Name: "joe", Age: 30},
		{ID: 2, Name: "sally", Age: 31},
	}, users)
}

@stephennancekivell stephennancekivell changed the title Add support for clickhouse settings Add support for clickhouse settings in NamedExec's fixBounds Oct 4, 2024
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.

1 participant