Titanium JIRA Archive
Alloy (ALOY)

[ALOY-634] Alloy: Create a Model that contains a field/column with a Default value of CURRENT_TIMESTAMP

GitHub Issuen/a
TypeImprovement
PriorityLow
StatusResolved
ResolutionWon't Fix
Resolution Date2014-03-10T19:13:04.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsModels, Runtime, XML
Labelsalloy, database, models
ReporterMark Anthony Sabandal
AssigneeUnknown
Created2013-04-18T17:48:59.000+0000
Updated2018-03-07T22:26:05.000+0000

Description

The current alloy 1.1.0 Models doesn't support creating a Column with a Default value of CURRENT_TIMESTAMP. I've already tested the following configurations: Not Working
config: {
      "columns": {
            "date_created": "TIMESTAMP"
      },
      "defaults": {
            "date_created": "CURRENT_TIMESTAMP"
      },
      "adapter": {
            "type": "sql",
            "collection_name": "Table1"
      }
}
Not Working
config: {
      "columns": {
            "date_created": "TIMESTAMP DEFAULT CURRENT_TIMESTAMP"
      },
      "defaults": {
 
      },
      "adapter": {
            "type": "sql",
            "collection_name": "Table1"
      }
}

Comments

  1. Tim Poulsen 2014-02-28

    Is there a reason you can't do this?
       exports.definition = {
         config: {
           "columns" : {
               "name" : "text",
               "date_created" : "text"
           },
           "defaults" : {
               "date_created": new Date()
           },
           adapter: {
             type: "sql",
             collection_name: "mycollection"
           }
         }
       
  2. Tim Poulsen 2014-03-10

    Marking resolved/won't fix because there's a suitable technique already. Not that SQLite doesn't offer support for datetime-type data types for fields. To simulate these, we'd have to pass through the date and time functions (http://sqlite.org/lang_datefunc.html) which offer no inherent advantage over the JavaScript functions that can be executed directly.

JSON Source