Question

I'm creating some models in Titanium studio using Alloy. I'd like some of the columns to be a date or a boolean, but it doesn't accept it when I run the app.

According to the documentation:

The following data types are accepted and mapped to the appropriate SQLite type: string, varchar, int, tinyint, smallint, bigint, double, float, decimal, number, date, datetime and boolean.

But when I run my app, I get this message in the console:

[WARN] :   "date" is not a valid sqlite field, using TEXT instead
[WARN] :   "date" is not a valid sqlite field, using TEXT instead
[WARN] :   "boolean" is not a valid sqlite field, using INTEGER instead
[WARN] :   "boolean" is not a valid sqlite field, using INTEGER instead

Perhaps I am setting my Models up incorrectly? Here is my code:

exports.definition = {
    config: {
        columns: {
                "availability_end": "date", 
                "availability_start": "date",          
                "deleted": "boolean", 
                "duration": "integer", 
                "title": "text",        
            },
        adapter: {
            type: "sql",
            collection_name: "videos"
            }
    },
/* the rest of the model definition... */
Était-ce utile?

La solution

Because it isn't a valid SQLite data type. http://www.sqlite.org/datatype3.html

1.2 Date and Time Datatype

SQLite does not have a storage class set aside for storing dates and/or times. Instead, the built-in Date And Time Functions of SQLite are capable of storing dates and times as TEXT, REAL, or INTEGER values:

TEXT as ISO8601 strings ("YYYY-MM-DD HH:MM:SS.SSS"). REAL as Julian day numbers, the number of days since noon in Greenwich on November 24, 4714 B.C. according to the proleptic Gregorian calendar. INTEGER as Unix Time, the number of seconds since 1970-01-01 00:00:00 UTC. Applications can chose to store dates and times in any of these formats and freely convert between formats using the built-in date and time functions.

Perhaps the documentation is just telling you that it automatically maps it properly. Maybe it also manages the date operations for you automatically.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top