Giter VIP home page Giter VIP logo

Comments (12)

jasdel avatar jasdel commented on May 20, 2024

Thanks for the feedback @kaihendry. To help improve the usability of the DynamoDB expressions, we created the DynamoDB expression package. This package provides a lot of builders to construct these expressions so you don't have to do it by hand. The package takes care of the escaping, and reserved words.

This will address most of the issue that you're running into with the expression statement. Here is an example for building an Update expression.

from aws-sdk-go-v2.

Doug-AWS avatar Doug-AWS commented on May 20, 2024

Sorry about that. The old link was to a test I ran. The developer guide has an example: https://docs.aws.amazon.com/sdk-for-go/v1/developer-guide/dynamo-example-update-table-item.html

from aws-sdk-go-v2.

kaihendry avatar kaihendry commented on May 20, 2024

@Doug-AWS

~$ curl https://alpha-docs-aws.amazon.com/sdk-for-go/v1/developer-guide/dynamo-example-update-table-item.html
curl: (6) Could not resolve host: alpha-docs-aws.amazon.com

from aws-sdk-go-v2.

kaihendry avatar kaihendry commented on May 20, 2024

Found a great example via Github search here: https://github.com/aws/aws-sdk-go-v2/blob/master/service/dynamodb/expression/examples_test.go

github.com/aws/aws-sdk-go-v2/service/dynamodb/expression is a godsend! However if my values are empty strings, boolean "true" seem to get set in my results. My workaround is to check they are empty atm.

from aws-sdk-go-v2.

kaihendry avatar kaihendry commented on May 20, 2024

Hmm, also noticed I don't have to dynamodbattribute.MarshalList my values when using this. Less code. I'm all for it.

from aws-sdk-go-v2.

jasdel avatar jasdel commented on May 20, 2024

Thanks for the feedback @kaihendry. You can add the struct tag dynamodb:",omitempty" to the fields that should be not be marshaled. This tag works similar to JSON's omitempty and will not marshal the field if it is a nil pointer or zero value.

Alternatively, you can create a dynamodbattribute.Encoder manually and set the "NULLEmptyString" option to instruct the encoder to replace empty string fields with NULL.

from aws-sdk-go-v2.

kaihendry avatar kaihendry commented on May 20, 2024

Cool, will try. But the default "true" is a bit unexpected for an empty value, no?

from aws-sdk-go-v2.

xibz avatar xibz commented on May 20, 2024

@kaihendry - The encoding/json package works the same way. So we wanted to be consistent with what the standard library was already doing.

from aws-sdk-go-v2.

kaihendry avatar kaihendry commented on May 20, 2024

@xibz .. wait, in JSON strings are empty when empty. Not booleans!

cat Gopkg.toml
[[constraint]]
  name = "github.com/aws/aws-sdk-go-v2"
  version = "2.0.0-preview.1"

https://play.golang.org/p/f7HC9x2iBNp

from aws-sdk-go-v2.

jasdel avatar jasdel commented on May 20, 2024

Thanks for the sample code @kaihendry. I think what you're seeing here is a confusing aspect of the DynamoDB Console's UI. If you click on foobar item and view its details in the console you'll see the Title field's value isn't true, but null. I think the DynamoDB Console UI is showing the wrong value here. It should be showing null instead.

It would be very helpful if you could use the DynamoDB console's Feedbacklink in the far bottom left hand corner of the screen to send this UI bug to the DynamoDB console team.

screen shot 2018-01-15 at 9 54 35 am

Here's what the text view of the item's value probably looks like.

screen shot 2018-01-15 at 9 54 58 am

from aws-sdk-go-v2.

kaihendry avatar kaihendry commented on May 20, 2024

Argh, you're right. Sorry for the noise. 🤦‍♂️

from aws-sdk-go-v2.

github-actions avatar github-actions commented on May 20, 2024

We have noticed this issue has not received attention in 1 year. We will close this issue for now. If you think this is in error, please feel free to comment and reopen the issue.

from aws-sdk-go-v2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.