You've already forked crud_generator
							
							
				mirror of
				https://github.com/ManyakRus/crud_generator.git
				synced 2025-10-31 00:17:48 +02:00 
			
		
		
		
	сделал RETURNING "id"
This commit is contained in:
		| @@ -45,7 +45,9 @@ func Create_ctx(ctx context.Context, db postgres_pgx.IConnectionTransaction, m * | ||||
| 	} | ||||
|  | ||||
| 	// | ||||
| 	TextSQL := TextSQL_Create_WithoutID | ||||
| 	TextSQL := TextSQL_Create_WithoutID + ` | ||||
| RETURNING ReplaceColumnNamesPK; | ||||
| ` | ||||
|  | ||||
| 	//массив, в котором значения всех полей и ИД | ||||
| 	MassValues := make([]interface{}, 0) | ||||
| @@ -59,13 +61,12 @@ func Create_ctx(ctx context.Context, db postgres_pgx.IConnectionTransaction, m * | ||||
|  | ||||
|  | ||||
| 	// | ||||
| 	_, err = db.Exec(ctx, TextSQL, MassValues...) | ||||
| 	err = db.QueryRow(ctx, TextSQL, MassValues...).Scan(ReplacePKFieldsWithAmpersandComma) | ||||
| 	if err != nil { | ||||
| 		err = fmt.Errorf(m.TableNameDB()+" Create_ctx() ReplacePKFieldNamesFormat error: %w", ReplacePKFieldsWithComma, err) | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
|  | ||||
| 	return err | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -110,18 +110,22 @@ func CreateFiles_Create1(Text string, Table1 *types.Table) string { | ||||
| 	ReplaceTextSQLCreateWithoutID_values_id := "" | ||||
| 	ColumnsPK := create_files.Find_PrimaryKeyColumns(Table1) | ||||
| 	ReplacePKFieldsWithComma := "" | ||||
| 	ReplacePKFieldsWithAmpersandComma := "" | ||||
| 	ReplacePKFieldNamesFormat := "" | ||||
| 	ReplaceColumnNamesPK := "" | ||||
| 	ReplaceIDNot0 := "" | ||||
| 	Comma := "" | ||||
| 	NewLineTT := "" | ||||
| 	TextAnd := "" | ||||
| 	TextOR := "" | ||||
| 	//CommaNewLineIf := "" | ||||
| 	CommaNewLine := "" | ||||
| 	NumberID := len(MassAllColumns) - len(ColumnsPK) | ||||
| 	for _, Column1 := range ColumnsPK { | ||||
| 		NumberID = NumberID + 1 | ||||
| 		sNumberID := strconv.Itoa(NumberID) | ||||
| 		ReplacePKFieldsWithComma = ReplacePKFieldsWithComma + Comma + "m." + Column1.NameGo | ||||
| 		ReplacePKFieldsWithAmpersandComma = ReplacePKFieldsWithAmpersandComma + Comma + "&m." + Column1.NameGo | ||||
| 		ReplacePKFieldNamesFormat = ReplacePKFieldNamesFormat + Comma + Column1.NameGo + ": %v" | ||||
| 		TextEmpty := create_files.FindText_NotEqualEmpty(Column1, "m."+Column1.NameGo) | ||||
| 		ReplaceIDNot0 = ReplaceIDNot0 + TextAnd + TextEmpty | ||||
| @@ -136,17 +140,22 @@ func CreateFiles_Create1(Text string, Table1 *types.Table) string { | ||||
| 		} | ||||
| 		ReplaceMassValuesIDAppend = ReplaceMassValuesIDAppend + NewLineTT + "MassValues = append(MassValues, " + TextValue + ")" | ||||
|  | ||||
| 		ReplaceColumnNamesPK = ReplaceColumnNamesPK + CommaNewLine + `"` + Column1.Name + `"` | ||||
|  | ||||
| 		Comma = ", " | ||||
| 		TextAnd = " && " | ||||
| 		NewLineTT = "\n\t\t" | ||||
| 		TextOR = " || " | ||||
| 		//CommaNewLineIf = ",\n" | ||||
| 		CommaNewLine = ",\n\t" | ||||
| 	} | ||||
| 	Otvet = strings.ReplaceAll(Otvet, "ReplacePKFieldsWithComma", ReplacePKFieldsWithComma) | ||||
| 	Otvet = strings.ReplaceAll(Otvet, "ReplacePKFieldNamesFormat", ReplacePKFieldNamesFormat) | ||||
| 	Otvet = strings.ReplaceAll(Otvet, "ReplaceIDNot0", ReplaceIDNot0) | ||||
| 	Otvet = strings.ReplaceAll(Otvet, "ReplaceMassValuesIDAppend", ReplaceMassValuesIDAppend) | ||||
| 	Otvet = strings.ReplaceAll(Otvet, "ReplacePKNotEqual0", ReplacePKNotEqual0) | ||||
| 	Otvet = strings.ReplaceAll(Otvet, "ReplaceColumnNamesPK", ReplaceColumnNamesPK) | ||||
| 	Otvet = strings.ReplaceAll(Otvet, "ReplacePKFieldsWithAmpersandComma", ReplacePKFieldsWithAmpersandComma) | ||||
|  | ||||
| 	//все колонки | ||||
| 	ReplaceMassValuesAppend := "" | ||||
|   | ||||
		Reference in New Issue
	
	Block a user