| 1087 | } |
| 1088 | |
| 1089 | func ExampleDB_Model_discardUnknownColumns() { |
| 1090 | type Model1 struct { |
| 1091 | } |
| 1092 | |
| 1093 | var model1 Model1 |
| 1094 | _, err := pgdb.QueryOne(&model1, "SELECT 1 AS id") |
| 1095 | fmt.Printf("Model1: %v\n", err) |
| 1096 | |
| 1097 | type Model2 struct { |
| 1098 | tableName struct{} `pg:",discard_unknown_columns"` |
| 1099 | } |
| 1100 | |
| 1101 | var model2 Model2 |
| 1102 | _, err = pgdb.QueryOne(&model2, "SELECT 1 AS id") |
| 1103 | fmt.Printf("Model2: %v\n", err) |
| 1104 | |
| 1105 | // Output: Model1: pg: can't find column=id in model=Model1 (prefix the column with underscore or use discard_unknown_columns) |
| 1106 | // Model2: <nil> |
| 1107 | } |
| 1108 | |
| 1109 | func ExampleDB_Model_softDelete() { |
| 1110 | type Flight struct { |