Struct not updated on update #1492

Open
opened 2019-12-04 10:39:11 +00:00 by Ghost · 4 comments

I want to update Contact so I changed the value and run Engine.ID(o.ID).Nullable("addon").AllCols().Update(o) but in the update request there is no contact field :(

logs

2019-12-04 11:25:50.816 INFO Struct before
2019-12-04 11:25:50.817 INFO &{10 {1 Florian Bouillon 3 {1 Delta Wings Maison 45 avenue de la bourdonniere  france } Developpeur false 0} 1 20191204 La nouvelle console Nintendo ! 0  0001-01-01 00:00:00 +0000 UTC 0001-01-01 00:00:00 +0000 UTC [{pouet 1 semaine}] 5 semaines et 1 seconde Téléphone [] [] [] 0  [] 0 0  0001-01-01 00:00:00 +0000 UTC  0 []}
2019-12-04 11:25:50.818 INFO Request being done
[xorm] [info]  2019/12/04 11:25:50.819592 [SQL] UPDATE `offer` SET `custom_id` = ?, `object` = ?, `status` = ?, `addon`=?, `date` = ?, `real_date` = ?, `planning` = ?, `planning_total` = ?, `connection` = ?, `notes` = ?, `conditions` = ?, `payement` = ?, `validity_number` = ?, `validity_type` = ?, `designations` = ?, `total_ht` = ?, `total_ttc` = ?, `livraison` = ?, `pdf_id` = ?, `files` = ?, `updated` = ? WHERE `id`=? []interface {}{20191204, "La nouvelle console Nintendo !", 0, interface {}(nil), interface {}(nil), interface {}(nil), "[{\"text\":\"pouet\",\"time\":\"1 semaine\"}]", "5 semaines et 1 seconde", "Téléphone", "[]", "[]", "[]", 0, "", "[]", 0, 0, "", 0, "[]", "2019-12-04 11:25:50", 10}

Struct

type Offer struct {
	ID             int64           `json:"id"`
	Contact        contact.Contact `json:"contact" xorm:"int default 0"` // le contact
	ContactID      int64           `json:"contact_id" xorm:"-"`
	CustomID       int             `json:"custom_id"`         // l'identifiant Custom basé sur la date
	Object         string          `json:"object"`            // l'objet de l'offre
	Status         int             `json:"status"`            // le status de l'offre
	Addon          string          `json:"addon" xorm:"null"` // -a, -b, etc
	Date           time.Time       `json:"date"`              // date de demande offre
	RealDate       time.Time       `json:"real_date"`         // date de real
	Planning       []Planning      `json:"planning"`          // objet planning
	PlanningTotal  string          `json:"planing_total"`     // Total du planning
	Connection     string          `json:"connection"`        // Type de la connexion
	Notes          []string        `json:"notes"`             // list des notes
	Conditions     []string        `json:"conditions"`        // liste des conditions
	Payement       []string        `json:"payement"`          // liste des actions de paiement
	ValidityNumber int             `json:"validity_number"`   // Objet de validite
	ValidityType   string          `json:"validity_type"`     // Objet de validite
	Designations   []Designation   `json:"designations"`      // liste des designations
	TotalHT        float32         `json:"total_ht"`          //total du prix en HT
	TotalTTC       float32         `json:"total_ttc"`         //total du prix TTC
	Livraison      string          `json:"livraison"`         // Moyen de livraison
	Updated        time.Time       `json:"-" xorm:"updated"`  //updated a each update
	UpdatedMonth   string          `json:"-" xorm:"-"`
	PdfID          int64           `json:"pdf_id"`
	Files          []int64         `json:"files"`
}
I want to update `Contact` so I changed the value and run `Engine.ID(o.ID).Nullable("addon").AllCols().Update(o)` but in the update request there is no `contact` field :( logs ```logs 2019-12-04 11:25:50.816 INFO Struct before 2019-12-04 11:25:50.817 INFO &{10 {1 Florian Bouillon 3 {1 Delta Wings Maison 45 avenue de la bourdonniere france } Developpeur false 0} 1 20191204 La nouvelle console Nintendo ! 0 0001-01-01 00:00:00 +0000 UTC 0001-01-01 00:00:00 +0000 UTC [{pouet 1 semaine}] 5 semaines et 1 seconde Téléphone [] [] [] 0 [] 0 0 0001-01-01 00:00:00 +0000 UTC 0 []} 2019-12-04 11:25:50.818 INFO Request being done [xorm] [info] 2019/12/04 11:25:50.819592 [SQL] UPDATE `offer` SET `custom_id` = ?, `object` = ?, `status` = ?, `addon`=?, `date` = ?, `real_date` = ?, `planning` = ?, `planning_total` = ?, `connection` = ?, `notes` = ?, `conditions` = ?, `payement` = ?, `validity_number` = ?, `validity_type` = ?, `designations` = ?, `total_ht` = ?, `total_ttc` = ?, `livraison` = ?, `pdf_id` = ?, `files` = ?, `updated` = ? WHERE `id`=? []interface {}{20191204, "La nouvelle console Nintendo !", 0, interface {}(nil), interface {}(nil), interface {}(nil), "[{\"text\":\"pouet\",\"time\":\"1 semaine\"}]", "5 semaines et 1 seconde", "Téléphone", "[]", "[]", "[]", 0, "", "[]", 0, 0, "", 0, "[]", "2019-12-04 11:25:50", 10} ``` Struct ```golang type Offer struct { ID int64 `json:"id"` Contact contact.Contact `json:"contact" xorm:"int default 0"` // le contact ContactID int64 `json:"contact_id" xorm:"-"` CustomID int `json:"custom_id"` // l'identifiant Custom basé sur la date Object string `json:"object"` // l'objet de l'offre Status int `json:"status"` // le status de l'offre Addon string `json:"addon" xorm:"null"` // -a, -b, etc Date time.Time `json:"date"` // date de demande offre RealDate time.Time `json:"real_date"` // date de real Planning []Planning `json:"planning"` // objet planning PlanningTotal string `json:"planing_total"` // Total du planning Connection string `json:"connection"` // Type de la connexion Notes []string `json:"notes"` // list des notes Conditions []string `json:"conditions"` // liste des conditions Payement []string `json:"payement"` // liste des actions de paiement ValidityNumber int `json:"validity_number"` // Objet de validite ValidityType string `json:"validity_type"` // Objet de validite Designations []Designation `json:"designations"` // liste des designations TotalHT float32 `json:"total_ht"` //total du prix en HT TotalTTC float32 `json:"total_ttc"` //total du prix TTC Livraison string `json:"livraison"` // Moyen de livraison Updated time.Time `json:"-" xorm:"updated"` //updated a each update UpdatedMonth string `json:"-" xorm:"-"` PdfID int64 `json:"pdf_id"` Files []int64 `json:"files"` } ```
Owner

Is contact.Contact a struct?

Is `contact.Contact` a struct?
Author

yes

type Contact struct {
	Id         int64           `json:"id"`                   // is unique
	Firstname  string          `json:"firstname"`            // Prenom
	Lastname   string          `json:"lastname"`             //Nom de famille
	Civility   int             `json:"civility"`             //1 = Femme, 2 = Autre, 3 = homme
	CompanyId  company.Company `json:"company" xorm:"int"`   //Societe
	Job        string          `json:"job"`                  //Nom de son job
	RGPD       bool            `json:"rgpd" xorm:"rgpd"`     // Autorisation RGPD
	TmpCompany int64           `json:"tmp_company" xorm:"-"` //
}
yes ``` type Contact struct { Id int64 `json:"id"` // is unique Firstname string `json:"firstname"` // Prenom Lastname string `json:"lastname"` //Nom de famille Civility int `json:"civility"` //1 = Femme, 2 = Autre, 3 = homme CompanyId company.Company `json:"company" xorm:"int"` //Societe Job string `json:"job"` //Nom de son job RGPD bool `json:"rgpd" xorm:"rgpd"` // Autorisation RGPD TmpCompany int64 `json:"tmp_company" xorm:"-"` // } ```
Author

oh and the values returned by Update are 1 and nil

oh and the values returned by Update are `1` and `nil`
Author

any informations ?

any informations ?
lunny added the
need
test
label 2019-12-09 11:49:37 +00:00
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: xorm/xorm#1492
No description provided.