bsed / gorilla

Automatically exported from code.google.com/p/gorilla
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

[schema] Schema fails when loading to inline structs #29

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Prepare two http handlers
2. Load the data to inline structs:
  data := &struct{
    Test string
  }{}
  schema.Load(data, r.Form)
  // ...error handling and form parsing omitted
3. Gorilla will cache both struct specs under the same key. The second load is 
useless and doesn't return errors.

What is the expected output? What do you see instead?
The data loaded into the struct or an error at least.

Please provide any additional information below.
This function:
  http://code.google.com/p/gorilla/source/browse/gorilla/schema/load.go#546

returns "." for ALL inline structs, there are no differences.

Using other thing as key for the cache map, or giving an option to avoid 
caching the specs will fix the problem.

Original issue reported on code.google.com by ernestok...@gmail.com on 6 Nov 2011 at 6:58

Attachments:

GoogleCodeExporter commented 9 years ago
Meta-data from structs are cached. Anonymous structs will all have the same 
identifier, and that messed with what you were doing.

I'll have to change it to not cache the meta-data in this case (and log a 
warning), but for now just don't use anonymous structs.

Original comment by rodrigo.moraes on 7 Nov 2011 at 10:36

GoogleCodeExporter commented 9 years ago

Original comment by rodrigo.moraes on 7 Nov 2011 at 10:36

GoogleCodeExporter commented 9 years ago
This issue was closed by revision 9ea137d4ea47.

Original comment by rodrigo.moraes on 15 Feb 2012 at 10:52

GoogleCodeExporter commented 9 years ago
Note: Fixed only in the Go1 version.

Original comment by rodrigo.moraes on 15 Feb 2012 at 10:55