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

[Python 2] repeated StructuredProperty returns as empty list #345

Closed
rpanaro opened this issue Feb 25, 2020 · 3 comments
Closed

[Python 2] repeated StructuredProperty returns as empty list #345

rpanaro opened this issue Feb 25, 2020 · 3 comments
Assignees
Labels
priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. 🚨 This issue needs some love. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@rpanaro
Copy link

rpanaro commented Feb 25, 2020

Environment details

Python 2.7.17
google-cloud-ndb 1.0.1

Steps to reproduce

Currently trying to finish migration from old ndb and my repeated StructuredProperty returns from queries as empty lists. I suppose the data is in legacy format.

Code example

Models:

class Day(ndb.Model):
   times = ndb.StructuredProperty(Timespan, 't', repeated = True)
   ...
class Timespan(ndb.Model):
   start = ndb.IntegerProperty('s', required = True)
   duration = ndb.IntegerProperty('d', required = True)
   varies = ndb.BooleanProperty('v')
   title = ndb.StringProperty('t')
   l = ndb.ComputedProperty(lambda self: self.title.lower())
   color = ndb.StringProperty('c')
   detail = ndb.TextProperty('i')

Query:
day = Day.query([filter]).get() results in day.times being []

Data Log

on Read & Write:

....
    properties {
      key: "t.c"
      value {
        array_value {
          values {
            string_value: "blue"
          }
          values {
            string_value: "green"
          }
        }
      }
    }
    properties {
      key: "t.d"
      value {
        array_value {
          values {
            integer_value: 3
          }
          values {
            integer_value: 4
          }
        }
      }
    }
    properties {
      key: "t.i"
      value {
        array_value {
          values {
            string_value: "foo text"
          }
          values {
            string_value: "bar text"
          }
        }
      }
    }
    properties {
      key: "t.l"
      value {
        array_value {
          values {
            string_value: "foo"
          }
          values {
            string_value: "bar"
          }
        }
      }
    }
    properties {
      key: "t.s"
      value {
        array_value {
          values {
            integer_value: 58
          }
          values {
            integer_value: 66
          }
        }
      }
    }
    properties {
      key: "t.t"
      value {
        array_value {
          values {
            string_value: "foo"
          }
          values {
            string_value: "bar"
          }
        }
      }
    }
    properties {
      key: "t.v"
      value {
        array_value {
          values {
            null_value: NULL_VALUE
          }
          values {
            null_value: NULL_VALUE
          }
        }
      }
    }
...

Possibly similar to a combo of #122 and/or #300 ??

@cguardia cguardia self-assigned this Feb 25, 2020
@yoshi-automation yoshi-automation added the 🚨 This issue needs some love. label Feb 25, 2020
@cguardia cguardia added 🚨 This issue needs some love. and removed triage me I really want to be triaged. labels Feb 26, 2020
@cguardia
Copy link
Contributor

@rpanaro there's a bug in the handling of legacy structured properties with names that differ from code names (like "t" instead of "times"). Fix coming up today.

@cguardia
Copy link
Contributor

Fixed via #347.

@rpanaro
Copy link
Author

rpanaro commented Feb 27, 2020

@cguardia Ah, my old friend over-optimization strikes again! Thanks much Carlos. Appreciate ya

@yoshi-automation yoshi-automation added the 🚨 This issue needs some love. label Apr 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. 🚨 This issue needs some love. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

3 participants