question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Storing embedded entity, it's ignoring exclude_from_indexes from embedded

See original GitHub issue

I’m trying to have a embedded entity with a field that is larger than 1500bytes. I add that field to the exclude_from_indexes key of the embedded entity. When I try and save the parent Entity it tells me the field is bigger than 1500bytes. If I save the embedded entity independently, it works.

Is exclude_from_indexes ignored on embedded entity?

client = datastore.Client(dataset_id=projectID)
record_key = client.key('Record', my_id)
record_entity = datastore.Entity(record_key)

embedded_key = client.key('Data', another_id)
embedded_entity = datastore.Entity(key=embedded_key,exclude_from_indexes=('big_field',))
embedded_entity['field1']='1234'
embedded_entity['big_field']='large string bigger than 1500bytes'

record_entity['RandomFieldName']=embedded_entity

client.put(record_entity)
#Error: gcloud.exceptions.BadRequest: 400 The value of property "big_field" is longer than 1500 bytes.

client.put(embedded_entity)
#No Error

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:11 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
dhermescommented, Dec 21, 2015

@igama This has been fixed:

>>> from gcloud import datastore
>>> from gcloud.environment_vars import TESTS_DATASET
>>> from gcloud.datastore import client
>>> client.DATASET = TESTS_DATASET
>>> CLIENT = datastore.Client()
>>> record_key = CLIENT.key('Record', 1234)
>>> record_entity = datastore.Entity(record_key)
>>> embedded_key = CLIENT.key('Data', 5678)
>>> embedded_entity = datastore.Entity(key=embedded_key, exclude_from_indexes=('big_field',))
>>> embedded_entity['field1'] = '1234'
>>> embedded_entity['big_field'] = 'large string bigger than 1500bytes ' * 50
>>> len(embedded_entity['big_field'])
1750
>>> record_entity['RandomFieldName'] = embedded_entity
>>> CLIENT.put(record_entity)
>>> CLIENT.put(embedded_entity)
>>> 
>>> CLIENT.delete(record_entity.key)
>>> CLIENT.delete(embedded_entity.key)
0reactions
igamacommented, Dec 30, 2015

@dhermes thank you, Will try it in the next days.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Storing embedded entity in Datastore, it's ignoring ...
I add that field to the exclude_from_indexes key of the embedded entity. When I try and save the parent Entity it tells me...
Read more >
Entities, Properties, and Keys | Cloud Datastore Documentation
A property can be indexed or unindexed (queries that order or filter on a property p will ignore entities where p is unindexed)....
Read more >
Chapter 4. Mapping entities to the index structure
In our example, because depth is set to 1, any @IndexedEmbedded attribute in Owner (if any) will be ignored. Using @IndexedEmbedded for object...
Read more >
com.google.cloud.datastore.FullEntity Java Examples
Same for maps and embedded entities which are stored as EntityValue. if (convertedVal. ... findById("ignored", TestEntity.class); return "all done"; ...
Read more >
Annotations :: Morphia Docs
Indexes; Index; Entity Mapping; Entity; Reference; Embedded; Validation ... @NotSaved instructs Morphia to ignore this field when saving but will still be ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found