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

1.6.0 automatically generating ID error #54

Open
wangnan1990 opened this issue Nov 5, 2021 · 0 comments
Open

1.6.0 automatically generating ID error #54

wangnan1990 opened this issue Nov 5, 2021 · 0 comments
Labels
bug Something isn't working

Comments

@wangnan1990
Copy link

When I use objectBox to auto-generate for entities that don't have any associated relationships, the information about IDs looks like this, Property<UserInfo, Id, Id>, and the documentation, shows that it should be generated correctly as Property<UserInfo, Id, Void>, so when I build a query statement about IDs, I am prompted with the incorrect type.

This is my entity:

// objectbox: entity
public class UserInfo {

// objectbox: id = {"assignable":true}
public var entityId: Id = 0;

public var name: String?;

public var nick: String?;

}

The following is the automatically generated code:

 /// Generated entity property information.
///
/// You may want to use this in queries to specify fetch conditions, for example:
///
///     box.query { UserInfo.entityId == myId }
public static var entityId: Property<UserInfo, Id, Id> { return Property<UserInfo, Id, Id>(propertyId: 1, isPrimaryKey: true) }
/// Generated entity property information.
///
/// You may want to use this in queries to specify fetch conditions, for example:
///
///     box.query { UserInfo.name.startsWith("X") }
public static var name: Property<UserInfo, String?, Void> { return Property<UserInfo, String?, Void>(propertyId: 2, isPrimaryKey: false) }
/// Generated entity property information.
///
/// You may want to use this in queries to specify fetch conditions, for example:
///
///     box.query { UserInfo.nick.startsWith("X") }
public static var nick: Property<UserInfo, String?, Void> { return Property<UserInfo, String?, Void>(propertyId: 3, isPrimaryKey: false) }
/// Generated entity property information.

And the "Property" is:

public struct Property<E, V, R> where E : ObjectBox.EntityInspectable, E : ObjectBox.__EntityRelatable, E == E.EntityBindingType.EntityType, V : ObjectBox.EntityPropertyTypeConvertible {

    /// Entity type that contains the property this object is describing.
    public typealias EntityType = E

    /// Supported property value type this is describing.
    public typealias ValueType = V

    /// If this is a ToOne property, this is the type it refers to. Otherwise Void.
    public typealias ReferencedType = R

    public init(propertyId: UInt32, isPrimaryKey: Bool = false)

    /// Indicates if the property is the entity's primary key.
    public var isPrimaryKey: Bool { get }

    /// The internal ID of the property, in terms of the database schema.
    public var propertyId: UInt32 { get }

}

So, when I use to build anbout “ID” query, It is always wrong.

@wangnan1990 wangnan1990 added the bug Something isn't working label Nov 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant