@@ -167,18 +167,18 @@ public dynamic DefaultValue(dynamic column)
167167 if ( String . IsNullOrEmpty ( def ) )
168168 {
169169 result = null ;
170- }
171- else if ( def == "getdate()" || def == "(getdate()) ")
172- {
173- result = DateTime . Now . ToShortDateString ( ) ;
174- }
175- else if ( def == "newid() " )
176- {
177- result = Guid . NewGuid ( ) . ToString ( ) ;
178- }
179- else
180- {
181- result = def . Replace ( "(" , "" ) . Replace ( ")" , " ") ;
170+ }
171+ else if ( def == "CURRENT_TIME " )
172+ {
173+ result = DateTime . UtcNow . ToString ( "HH:mm:ss" ) ;
174+ }
175+ else if ( def == "CURRENT_DATE " )
176+ {
177+ result = DateTime . UtcNow . ToString ( "yyyy-MM-dd" ) ;
178+ }
179+ else if ( def == "CURRENT_TIMESTAMP" )
180+ {
181+ result = DateTime . UtcNow . ToString ( "yyyy-MM-dd HH:mm:ss ") ;
182182 }
183183 return result ;
184184 }
@@ -207,9 +207,22 @@ public dynamic Prototype
207207 public IEnumerable < dynamic > Schema
208208 {
209209 get
210- {
211- if ( _schema == null )
212- _schema = Query ( "SELECT * FROM sqlite_master WHERE type = 'table' and name = @0" , TableName ) ;
210+ {
211+ if ( _schema == null )
212+ {
213+ var rows = new List < dynamic > ( ) ;
214+ foreach ( var row in Query ( "PRAGMA table_info('" + TableName + "')" ) )
215+ {
216+ rows . Add ( new
217+ {
218+ COLUMN_NAME = ( row as IDictionary < string , object > ) [ "name" ] . ToString ( ) ,
219+ DATA_TYPE = ( row as IDictionary < string , object > ) [ "type" ] . ToString ( ) ,
220+ IS_NULLABLE = ( row as IDictionary < string , object > ) [ "notnull" ] . ToString ( ) == "0" ? "NO" : "YES" ,
221+ COLUMN_DEFAULT = ( row as IDictionary < string , object > ) [ "dflt_value" ] ?? "" ,
222+ } ) ;
223+ }
224+ _schema = rows ;
225+ }
213226 return _schema ;
214227 }
215228 }
0 commit comments