Explorar el Código

added TimeStamp spod macros support

Nicolas Cannasse hace 14 años
padre
commit
2c0d4887f2
Se han modificado 5 ficheros con 17 adiciones y 3 borrados
  1. 1 1
      std/sys/db/Manager.hx
  2. 1 0
      std/sys/db/SpodInfos.hx
  3. 11 2
      std/sys/db/SpodMacros.hx
  4. 1 0
      std/sys/db/TableCreate.hx
  5. 3 0
      std/sys/db/Types.hx

+ 1 - 1
std/sys/db/Manager.hx

@@ -148,7 +148,7 @@ class Manager<T : Object> {
 						Reflect.setField(x, f, "");
 					case DSmallBinary, DNekoSerialized, DLongBinary, DBytes(_), DBinary:
 						Reflect.setField(x, f, haxe.io.Bytes.alloc(0));
-					case DDate, DDateTime:
+					case DDate, DDateTime, DTimeStamp:
 						// default date might depend on database
 					case DId, DUId, DBigId, DNull, DInterval, DEncoded:
 						// no default value for these

+ 1 - 0
std/sys/db/SpodInfos.hx

@@ -37,6 +37,7 @@ enum SpodType {
 	DString( n : Int );
 	DDate;
 	DDateTime;
+	DTimeStamp;
 	DTinyText;
 	DSmallText;
 	DText;

+ 11 - 2
std/sys/db/SpodMacros.hx

@@ -113,6 +113,15 @@ class SpodMacros {
 		return null;
 		#end
 	}
+	
+	public dynamic function getManager( t : haxe.macro.Type, p : Position ) : SpodMacros {
+		#if macro
+		return getManagerInfos(t, p);
+		#else
+		throw "not implemented";
+		return null;
+		#end
+	}
 
 	function makeInt( t : haxe.macro.Type ) {
 		switch( t ) {
@@ -395,7 +404,7 @@ class SpodMacros {
 		case DBigId, DBigInt, DSingle, DFloat: 1;
 		case DBool: 2;
 		case DString(_), DTinyText, DSmallText, DText, DSerialized: 3;
-		case DDate, DDateTime: 4;
+		case DDate, DDateTime, DTimeStamp: 4;
 		case DSmallBinary, DLongBinary, DBinary, DBytes(_), DNekoSerialized: 5;
 		case DInterval: 6;
 		case DNull: 7;
@@ -531,7 +540,7 @@ class SpodMacros {
 					var mpath = { expr : EConst(first.charCodeAt(0) <= 'Z'.code ? CType(first) : CIdent(first)), pos : p };
 					for( e in path )
 						mpath = { expr : e.charCodeAt(0) <= 'Z'.code ? EType(mpath, e) : EField(mpath, e), pos : p };
-					var m = getManagerInfos(typeof(mpath), p);
+					var m = getManager(typeof(mpath),p);
 					var getid = { expr : ECall( { expr : EField(mpath, "unsafeGetId"), pos : p }, [f.expr]), pos : p };
 					f.field = r.key;
 					f.expr = ensureType(getid, m.inf.hfields.get(m.inf.key[0]).t);

+ 1 - 0
std/sys/db/TableCreate.hx

@@ -40,6 +40,7 @@ class TableCreate {
 		case DString(n): "VARCHAR("+n+")";
 		case DDate: "DATE";
 		case DDateTime: "DATETIME";
+		case DTimeStamp: "TIMESTAMP DEFAULT 0";
 		case DTinyText: "TINYTEXT";
 		case DSmallText: "TEXT";
 		case DText, DSerialized: "MEDIUMTEXT";

+ 3 - 0
std/sys/db/Types.hx

@@ -59,6 +59,9 @@ typedef SDate = Date
 /** mysql DateTime **/
 typedef SDateTime = Date
 
+/** mysql Timestamp **/
+typedef STimeStamp = Date
+
 /** TinyText (up to 255 bytes) **/
 typedef STinyText = String