objectbox-swift
objectbox-swift copied to clipboard
1.6.0 automatically generating ID error
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.