@@ -35,7 +35,23 @@ var CockroachDriver = Base.extend({
3535 return this . runSql ( sql ) . nodeify ( callback ) ;
3636 } ,
3737
38- _handleMultiPrimaryKeys : function ( primaryKeyColumns ) {
38+ _translateSpecialDefaultValues : function (
39+ spec ,
40+ options ,
41+ tableName ,
42+ columnName
43+ ) {
44+ switch ( spec . defaultValue . special ) {
45+ case 'CURRENT_TIMESTAMP' :
46+ spec . defaultValue . prep = 'CURRENT_TIMESTAMP()' ;
47+ break ;
48+ default :
49+ this . super ( spec , options , tableName , columnName ) ;
50+ break ;
51+ }
52+ } ,
53+
54+ _handleMultiPrimaryKeys : function ( primaryKeyColumns ) {
3955 return util . format (
4056 ', PRIMARY KEY (%s)' ,
4157 this . quoteDDLArr (
@@ -253,7 +269,7 @@ var CockroachDriver = Base.extend({
253269 if ( spec . autoIncrement ) {
254270 if ( this . mapDataType ( spec . type ) === 'uuid' ) {
255271 constraint . push ( 'UUID' ) ;
256- spec . defaultValue = { raw : 'gen_random_uuid()' } ;
272+ spec . defaultValue = { prep : 'gen_random_uuid()' } ;
257273 } else {
258274 constraint . push ( 'SERIAL' ) ;
259275 }
@@ -278,10 +294,12 @@ var CockroachDriver = Base.extend({
278294
279295 if ( spec . defaultValue !== undefined ) {
280296 constraint . push ( 'DEFAULT' ) ;
281- if ( typeof spec . defaultValue === 'string' && ! spec . defaultValue . raw ) {
297+ if ( typeof spec . defaultValue === 'string' ) {
282298 constraint . push ( "'" + spec . defaultValue + "'" ) ;
283299 } else if ( spec . defaultValue . raw ) {
284300 constraint . push ( spec . defaultValue . raw ) ;
301+ } else if ( spec . defaultValue . prep ) {
302+ constraint . push ( spec . defaultValue . prep ) ;
285303 } else {
286304 constraint . push ( spec . defaultValue ) ;
287305 }
0 commit comments