Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8913405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:27:22+00:00 2026-06-15T04:27:22+00:00

Hey guys im trying to figure out how to structure my query for the

  • 0

Hey guys im trying to figure out how to structure my query for the following case

First i have a model defined

class Variant(ndb.Expando):
    test = ndb.StringProperty()


class Item(ndb.Model):
    test2 = ndb.StringProperty()
    variants = ndb.StructuredProperty(Variant, repeated=True)

variant = Variant(test="test", dynamic="a")
item = Item(test2="test", variants=[variant, ])
item.put()

and then for the query stuff.. So far i’ve tried

dynamic = "dynamic"
Item.query(ndb.GenericProperty("variants.%s" % dynamic) == "a")
Item.query(Item._properties["variants.%s" % dynamic] == "a")
Item.query(getattr(Item.variants, dynamic) == "a")
Item.query(getattr(Item, "variants.%s" % dynamic) == "a")
Item.query(ndb.query.FilterNode("variants.%s" % dynamic, "=", "a"))

generic_prop = ndb.GenericProperty()
generic_prop._name = "variants.%s" % dynamic
Item.query(generic_prop == "a")

and none of these works.. This should be perfectly possible since the property name in the datastore is

variants.dynamic = ["a", ]

Thank you for your help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T04:27:23+00:00Added an answer on June 15, 2026 at 4:27 am

    It’s easy using GQL:

    Item.gql("WHERE variants.dynamic = 'a'").fetch()
    

    Also this works:

    s = StringProperty()
    s._name = 'variants.dynamic')
    Item.query(s == 'a').fetch()
    

    Please do file a feature request; however it’s going to be a balancing act. What syntax would you like to use?

    UPDATE:

    The same thing works with GenericProperty(), or any other Property subclass.

    The reason that GenericProperty(‘variants.dynamic’) is forbidden is to prevent people from doing hacks like this:

    class MyHack(ndb.Model):
      foo = StringProperty('bar.baz')
    

    which will confuse the serialization and deserialization code.

    Maybe we can add a flag to Property that skips this check but then disallows using the property in a model definition (it would only allow it in a query).

    Or maybe we can make this work (I think this would be hard though):

    Item.query(Item.variants.dynamic == 'a').fetch()
    

    (only if variants is an Expando).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey guys, I have the following HTML structure that I am trying to pull
Hey guys so I have been trying to figure out why my update function
Hey Guys, Ok so I have been trying to figure this out for the
Hey guys, I am trying to figure out how to disable the ability for
hey guys, I'm trying to figure out a way for my controller to activate
Hey guys i'm trying to figure out how to subtract one time from another
Hey guys i'm trying to figure out how to draw a bitmap that i
Hey guys, have a little issue i need to figure out. I created a
Hey guys - I'm tearing my hair out trying to create a regular expression
Hey guys I am getting this exception when trying to run the query Column

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.