added unsigned int to mysql types
This commit is contained in:
		
							
								
								
									
										8
									
								
								db.go
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								db.go
									
									
									
									
									
								
							@@ -130,7 +130,7 @@ func (db *Db) QueryAssociativeArray(query string) (Rows, error) {
 | 
			
		||||
							return nil, err
 | 
			
		||||
						}
 | 
			
		||||
						m[colName] = i
 | 
			
		||||
					case "UNSIGNED BIGINT":
 | 
			
		||||
					case "UNSIGNED BIGINT", "UNSIGNED INT":
 | 
			
		||||
						u, err := strconv.ParseUint(fmt.Sprintf("%s", *val), 10, 64)
 | 
			
		||||
						if err != nil {
 | 
			
		||||
							return nil, err
 | 
			
		||||
@@ -615,7 +615,8 @@ func buildLinks(schema []TableInfo) []Link {
 | 
			
		||||
	return links
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (db *Db) GenerateTemplate(templateFilename string, generatedFilename string) error {
 | 
			
		||||
// Generate templates from a schema
 | 
			
		||||
func (db *Db) GenerateSchemaTemplate(templateFilename string, generatedFilename string) error {
 | 
			
		||||
	schema, err := db.GetSchema()
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		log.Println(err)
 | 
			
		||||
@@ -648,6 +649,7 @@ func (db *Db) GenerateTemplate(templateFilename string, generatedFilename string
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Generate tables
 | 
			
		||||
func (db *Db) GenerateTableTemplates(templateFilename string, outputFolder string, extension string) error {
 | 
			
		||||
	schema, err := db.GetSchema()
 | 
			
		||||
	if err != nil {
 | 
			
		||||
@@ -683,7 +685,7 @@ func FormatForSQL(datatype string, value interface{}) string {
 | 
			
		||||
	if !strings.Contains(datatype, "char") && len(strval) == 0 {
 | 
			
		||||
		return "NULL"
 | 
			
		||||
	}
 | 
			
		||||
	if strings.Contains(datatype, "char") || strings.Contains(datatype, "date") || strings.Contains(datatype, "timestamp") {
 | 
			
		||||
	if strings.Contains(datatype, "char") || strings.Contains(datatype, "text") || strings.Contains(datatype, "date") || strings.Contains(datatype, "timestamp") {
 | 
			
		||||
		return fmt.Sprint(pq.QuoteLiteral(strval))
 | 
			
		||||
	}
 | 
			
		||||
	return fmt.Sprint(strval)
 | 
			
		||||
 
 | 
			
		||||
@@ -217,7 +217,7 @@ func TestMySaveSchema(t *testing.T) {
 | 
			
		||||
func TestMyGenerateTemplate(t *testing.T) {
 | 
			
		||||
	db := Open("mysql", "test:test@tcp(127.0.0.1:3306)/test?parseTime=true")
 | 
			
		||||
	defer db.Close()
 | 
			
		||||
	err := db.GenerateTemplate("plantuml.tmpl", "schema.puml")
 | 
			
		||||
	err := db.GenerateSchemaTemplate("plantuml.tmpl", "schema.puml")
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		fmt.Println(err.Error())
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -217,7 +217,7 @@ func TestPgSaveSchema(t *testing.T) {
 | 
			
		||||
func TestPgGenerateTemplate(t *testing.T) {
 | 
			
		||||
	db := Open("postgres", "host=127.0.0.1 port=5432 user=test password=test dbname=test sslmode=disable")
 | 
			
		||||
	defer db.Close()
 | 
			
		||||
	err := db.GenerateTemplate("plantuml.tmpl", "schema.puml")
 | 
			
		||||
	err := db.GenerateSchemaTemplate("plantuml.tmpl", "schema.puml")
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		fmt.Println(err.Error())
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user