-
Notifications
You must be signed in to change notification settings - Fork 5
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
How to create a primary index using the couchbase-capella_query_indexes #259
Comments
We encountered this same issue and it looks like it's related to a bug in the provider code related to null checking the index name.
A variation of this code block is repeated throughout the provider at various scopes which makes it hard to tell when indexName is actually null or not. To resolve for now you can just modify your resource block, adding an index name:
|
The crux of this issue is that In the create function the local variable if !plan.IndexName.IsNull() {
indexName = plan.IndexName.ValueString()
} else {
indexName = "#primary"
}
ddl = fmt.Sprintf(
"CREATE PRIMARY INDEX `%s` ON `%s`.`%s`.`%s` WITH { \"defer_build\": %t, \"num_replica\": %d }",
indexName,
plan.BucketName.ValueString(),
plan.ScopeName.ValueString(),
plan.CollectionName.ValueString(),
plan.With.DeferBuild.ValueBool(),
plan.With.NumReplica.ValueInt64(),
) However later on in the create function after executing the statement there is a query of the index to get additional properties to enrich the state if state.BuildIndexes.IsNull() {
index, err := g.getQueryIndex(
ctx,
state.OrganizationId.ValueString(),
state.ProjectId.ValueString(),
state.ClusterId.ValueString(),
state.BucketName.ValueString(),
state.ScopeName.ValueString(),
state.CollectionName.ValueString(),
state.IndexName.ValueString(),
)
if err != nil {
resp.Diagnostics.AddError(
"Error reading query index",
"Could not read query index "+state.IndexName.ValueString()+": "+err.Error(),
)
return
}
state.Status = types.StringValue(index.Status)
state.With.NumReplica = types.Int64Value(int64(index.NumReplica))
} However, the query here is using the value from the state which is just the plan values and this value is empty. Its not taking into account the fact that earlier in the function there was logic to set the indexName local var to We can also see that the error we should get here should include the index name before the colon but we just get an empty string
|
I try to create a primary index on a collection using this code
The index will be created, but the provider will get the following error
I saw a doc in this PR, but It doesn't contain information about creating primary indexes
The text was updated successfully, but these errors were encountered: