Skip to content

Feedback requested for accessing property values #25

@blowmage

Description

@blowmage

How should Datastore's Entity behave when accessing properties that have not yet been set?

entity = Gcloud::Datastore::Entity.new
entity["name"] = "John Jacob Jingleheimer Schmidt"
puts entity["name"] #=> John Jacob Jingleheimer Schmidt
puts entity["email"] #=> ???

The current behavior is to return nil. Another option is to raise an error.

IMO the behavior should be permissive. Consider the case of a projection query where entity records stored in Datastore have both name and email, but only name is projected in the query. In ActiveRecord the attributes that are not selected are set to nil.

query = Gcloud::Datastore::Query.new.kind("User").select("name")
entities = Gcloud::Datastore.connection.run query
entities.each do |entity|
  puts entity["email"]
end

Thoughts?

Metadata

Metadata

Assignees

Labels

api: datastoreIssues related to the Datastore API.type: questionRequest for information or clarification. Not an issue.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions