Nullable int with Required attribute in Realms does not get stored - realm

What is going on here? Nullable ints appear to be fine, but as soon as you make it [Required], it gets stored as 0.
Assertion failure
Expected: 2
But was: 0

Related

In Dynamoose, how to specify schema for field that allows either String or NULL?

I'm trying to define the schema for a field that will either be a string value or NULL.
From what I can tell, this should work:
myField: [String, dynamoose.type.NULL]
However, when it encounters a null value in the table, I get the following error:
TypeMismatch: Expected example.myField to be of type string, instead found type null.
The only thing I've found that works is setting the field to dynamoose.type.ANY, which seems like it defeats the purpose of defining the field at all.

Firedac SQLite returning wrong values

I have a SQLite database that contains a table called "players". I can see in DB Browser that the data in the table is correct however when attempting to retrieve the data it seems to be returning a totally different value than what's in the database.
Value in DB: 76561198113034550
Value returned : 152768822
I'm getting the value with the following
qryPlayers.Close;
qryPlayers.SQL.Text := 'SELECT * FROM players';
qryPlayers.Open;
playerID := qryPlayers.FieldByName('steamid').Value; // .AsString returns the same value
Whats causing this and how can I fix it?
I just checked, what value the 4 lower bytes of 76561198113034550 have... And tadaaa, it is 152768822! So the upper 4 bytes are simply truncated.
Declare playerID as Int64, not Integer or Cardinal since those types only have 4 bytes in memory.
And for retrieving the value from the DB use qryPlayers.FieldByName('steamid').AsLargeInt.

How do I fix not null constraints error on flutter?

I have an db which has two table: note and category. There is a schema below for my tables. I want to insert a record to the note table but I'm getting this error below. Can anyone please help?
Here is the method I create for insert a record to note table and the error which I'm getting from this process.
It clearly states that you declared your category_id as NOT NULL but you are passing a null value while trying to insert a note.
There may be 2 approach here,
You can simply remove NOT NULL constraint from your table definition by modifiying "category_id" INTEGER NOT NULL DEFAULT 1 to "category_id" INTEGER DEFAULT 1
You should really be sure that you are passing a non-null value to category_id in insert operation
As I see from your logs, it clearly says that one of the argument you are passing is null and it causes this crash.
Hope these helps you to detect your problem and fix it.

Null integers in Flex

My database field is as is : num_in_stock, mediumint(8), NULL (yes)
I'm generating my services using the Connect to Data/Service tool in Flash Builder 4
What is the best course of action if I want my num_in_stock field to have a value of NULL, not zero (0) when we leave the field empty?
Thanks!
In Flash, you can't have an int as null. int and uint default to 0. Number however defaults to NaN. You could always convert your int to Number before it's sent over to Flash and make sure it's NaN. However, this would depend on your data transportation protocol (amf, json, etc..)

TableAdapter is returning phantom results in ASP.NET

I have a TableAdapter that is fetching rows from a stored procedure. For some reason, when there are no results, the TableAdapter returns an INT with value 0 instead of NULL. The stored procedure has NOCOUNT ON.
The problem with this is that I have a ListView in the frontend with an EmptyDataTemplate, which is not being shown. When I ran the query in Query Analyzer, I see that it is returning 0 instead of NULL.
The stored procedure has a simple 'SELECT * FROM WHERE ' with one INT parameter (NOT Output). Running it in Query Analyzer, I get no output, as expected.
What's going on?
Check the ExcuteMode property of the tableAdapter for the query. Be sure it is set to "Reader". There are 3 options for ExecuteMode:
Reader - Returns rows of data
Scalar - Returns single value
NonQuery - Returns an int with number of rows affected
Also check the Parameters Collection for a return value parameter. It should have properites AllowDBNull (true if you allow nulls), Direction (ReturnValue). This parameter should hold the results of your SP. In your example it would be null since there were no records returned.
It looks like the stored procedure is returning the result. All stored procedures return a result code. It's most likely this.

Resources