ActiveAndroid icon indicating copy to clipboard operation
ActiveAndroid copied to clipboard

SELECT NULL values

Open warrendeleon opened this issue 10 years ago • 4 comments

Hello,

I'm trying to SELECT all rows of table Measurement which column remoiteId is NULL. I'm using SQL sintax "ISNULL" or "IS NULL" but is not working. I'm using this code:

List<Measurement> measurements = new Select() .from(Measurement.class) .where("remoteId IS NULL") .execute();

Is there any way to accomplish this goal?

Thank you very much.

Warren de León Ofalla http://warrendeleon.com

warrendeleon avatar Mar 23 '15 18:03 warrendeleon

IS NULL should work. Can you give additional details such as what your Measurements class looks like?

CodyEngel avatar Apr 03 '15 18:04 CodyEngel

@Table(name = "Measurements") public class Measurement extends Model {

@Column
private Long remoteId;

@Column
private int urinatedVolume;

@Column
private int voidedVolume;

@Column
private Date time;

@Column(onUpdate = Column.ForeignKeyAction.CASCADE, onDelete = Column.ForeignKeyAction.CASCADE)
private Patient patient;

warrendeleon avatar Apr 03 '15 20:04 warrendeleon

My workoround was to set all Measurements with remoteId -1L and then I make an ActiveAndroid select for those Measurements with remoteId -1. I couldn't get null values with ActiveAndroid.

warrendeleon avatar Apr 03 '15 20:04 warrendeleon

As I'm sure you've figured out by now, your query should look something like new Select() .all() .from(Measurement.class) .where("remoteId IS NULL") .execute();

Issue can be closed, yeah?

sultanofcardio avatar Sep 30 '16 16:09 sultanofcardio