Fix #784 set mysql datetime's type to NOT NULL
This commit is contained in:
		
							parent
							
								
									94fb0dd1d4
								
							
						
					
					
						commit
						a7097106b1
					
				@ -61,7 +61,11 @@ func (mysql) DataTypeOf(field *StructField) string {
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
		case reflect.Struct:
 | 
							case reflect.Struct:
 | 
				
			||||||
			if _, ok := dataValue.Interface().(time.Time); ok {
 | 
								if _, ok := dataValue.Interface().(time.Time); ok {
 | 
				
			||||||
				sqlType = "timestamp NULL"
 | 
									if _, ok := field.TagSettings["NOT NULL"]; ok {
 | 
				
			||||||
 | 
										sqlType = "timestamp"
 | 
				
			||||||
 | 
									} else {
 | 
				
			||||||
 | 
										sqlType = "timestamp NULL"
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		default:
 | 
							default:
 | 
				
			||||||
			if _, ok := dataValue.Interface().([]byte); ok {
 | 
								if _, ok := dataValue.Interface().([]byte); ok {
 | 
				
			||||||
 | 
				
			|||||||
@ -42,7 +42,7 @@ type CreditCard struct {
 | 
				
			|||||||
	ID        int8
 | 
						ID        int8
 | 
				
			||||||
	Number    string
 | 
						Number    string
 | 
				
			||||||
	UserId    sql.NullInt64
 | 
						UserId    sql.NullInt64
 | 
				
			||||||
	CreatedAt time.Time
 | 
						CreatedAt time.Time `sql:"not null"`
 | 
				
			||||||
	UpdatedAt time.Time
 | 
						UpdatedAt time.Time
 | 
				
			||||||
	DeletedAt *time.Time
 | 
						DeletedAt *time.Time
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user