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

DynamoDB OverrideTableName doesn't work #1448

Closed
vickyRathee opened this issue Nov 7, 2019 · 6 comments
Closed

DynamoDB OverrideTableName doesn't work #1448

vickyRathee opened this issue Nov 7, 2019 · 6 comments
Labels
breaking-change This issue requires a breaking change to remediate. bug This issue is a bug. duplicate This issue is a duplicate. dynamodb

Comments

@vickyRathee
Copy link

vickyRathee commented Nov 7, 2019

I am using Table1 to override using DynamoDBOperationConfig.OverrideTableName but the SDK doesn't override the tableName and throwing error with class name Documents . So the override request not honored and getting error.

Error : Requested resource not found: Table: Documents not found

My requirement is to change the table name dynamically on business logic to insert documents in different tables. So I can't use the [DynamoDBTable("Table1")]

async Task Main()
{
	var document = new Documents {doc_id = "abc", name = "test", created = DateTime.UtcNow};
	
	string tableName = "Table1";
	var dynamo = new DynamoDbService(tableName);
	await dynamo.InsertDocumentAsync<Documents>(document);
	
}

public class DynamoDbService
{
	private static readonly string awsAccessKey = "access key here";
	private static readonly string awsSecretKey = "secret here";
	
	private static DynamoDBOperationConfig _operationConfig;

	private static BasicAWSCredentials awsCredentials = new BasicAWSCredentials(awsAccessKey, awsSecretKey);
	private static AmazonDynamoDBClient client = new AmazonDynamoDBClient(awsCredentials, RegionEndpoint.USEast1);
	private static DynamoDBContext context = new DynamoDBContext(client);

	public DynamoDbService(string tableName)
	{
		_operationConfig = new DynamoDBOperationConfig()
		{
			OverrideTableName = tableName
		};
	}
	
	public async Task InsertDocumentAsync<T>(T document)
	{
		await context.SaveAsync<T>(document);
	}

	public async Task<List<T>> GetDocumentsAsync<T>(string id, int limit = 10)
	{
		QueryFilter filter = new QueryFilter();
		filter.AddCondition("doc_id", QueryOperator.Equal, id);
		QueryOperationConfig queryConfig = new QueryOperationConfig
		{
			Filter = filter,
			Limit = limit,
			BackwardSearch = true
		};
		var documents = await context.FromQueryAsync<T>(queryConfig, _operationConfig).GetNextSetAsync();
		return documents;
	}
}

public class Documents
{
	public string doc_id { get; set; }
	public string name {get; set;}
	public DateTime created {get; set;}
}

image

@klaytaybai
Copy link
Contributor

Hi @vickyRathee, thanks for the time to provide the feedback on this. It is a known problem. You can see another report from #1218. We're looking for other approaches to fix this problem that wouldn't cause a breaking change for any customers depending on the flawed behavior.

@klaytaybai klaytaybai added duplicate This issue is a duplicate. bug This issue is a bug. labels Nov 7, 2019
@vickyRathee
Copy link
Author

@klaytaybai Thanks. But that's 9 month old issue if you are aware.. I think many DynamoDBv2 versions released after that. Any timeline when we can expect a fix?

@klaytaybai
Copy link
Contributor

Unless we can find a way to solve this without causing breaking changes, we have to wait until a major version based on our policy of not making breaking changes except for major versions.

@klaytaybai klaytaybai added breaking-change This issue requires a breaking change to remediate. and removed needs-major-version labels Feb 27, 2020
@jameswoodley
Copy link

So how are we supposed to use this? I need to use a table name override and can't right now. I think surely you should be focussing on those of us who want to use it as intended than those who are using a flawed version?

If you have to bump to a major version then please do, but otherwise this functionality is unusable?

@ashishdhingra
Copy link
Contributor

Refer #1218 (comment), this is a breaking change. Duplicate of #1421. Closing this one.

@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change This issue requires a breaking change to remediate. bug This issue is a bug. duplicate This issue is a duplicate. dynamodb
Projects
None yet
Development

No branches or pull requests

4 participants