PecanProject / bety

Web-interface to the Biofuel Ecophysiological Traits and Yields Database (used by PEcAn and TERRA REF)
https://www.betydb.org
BSD 3-Clause "New" or "Revised" License
16 stars 38 forks source link

Unable to insert string into species.spcd field (via psql or web interface) #133

Closed dlebauer closed 10 years ago

dlebauer commented 10 years ago

To reproduce the error in the web interface:

  1. go to https://www.betydb.org/species/2937/edit
  2. enter 'SASA21' in Spcd field
  3. click update
  4. observe that Spcd value is set to 0
  5. this is the production.log output:
Started POST "/species/2937" for 128.174.125.237 at 2014-09-03 10:54:41 -0500
  Processing by SpeciesController#update as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"/MVvTkbfZs3bn1QWK17WECTJZmNBRQHF0WU7aPboYRM=", "specie"=>{"spcd"=>"SASA21", "genus"=>"Salix", "species"=>"sachalinensis", "scientificname"=>"Salix sachalinensis", "commonname"=>"Sekka - Japanese Fantail Willow", "AcceptedSymbol"=>"ABES", "SynonymSymbol"=>"", "Symbol"=>"ABES", "PLANTS_Floristic_Area"=>"NA (L48), PR, VI", "State"=>"<strong>USA</strong> (CT, DC, FL, IL, KY, LA, MD, MI, MS, NC, SC, VA), <strong>USA+</strong> (PR, VI)", "Category"=>"Dicot", "Family"=>"Malvaceae", "FamilySymbol"=>"MALVAC", "FamilyCommonName"=>"Mallow family", "xOrder"=>"Malvales", "SubClass"=>"Dilleniidae", "Class"=>"Magnoliopsida", "SubDivision"=>"", "Division"=>"Magnoliophyta", "SuperDivision"=>"Spermatophyta", "SubKingdom"=>"Tracheobionta", "Kingdom"=>"Plantae", "ITIS_TSN"=>"21770", "Duration"=>"Annual, Perennial", "GrowthHabit"=>"Subshrub, Forb/herb", "NativeStatus"=>"L48 (I), PR (I), VI (I)", "NationalWetlandIndicatorStatus"=>"", "RegionalWetlandIndicatorStatus"=>"", "ActiveGrowthPeriod"=>"", "AfterHarvestRegrowthRate"=>"", "Bloat"=>"", "C2N_Ratio"=>"", "CoppicePotential"=>"", "FallConspicuous"=>"", "FireResistance"=>"", "FoliageTexture"=>"", "GrowthForm"=>"", "GrowthRate"=>"", "MaxHeight20Yrs"=>"0", "MatureHeight"=>"0", "KnownAllelopath"=>"", "LeafRetention"=>"", "Lifespan"=>"", "LowGrowingGrass"=>"", "NitrogenFixation"=>"", "ResproutAbility"=>"", "AdaptedCoarseSoils"=>"", "AdaptedMediumSoils"=>"", "AdaptedFineSoils"=>"", "AnaerobicTolerance"=>"", "CaCO3Tolerance"=>"", "ColdStratification"=>"", "DroughtTolerance"=>"", "FertilityRequirement"=>"", "FireTolerance"=>"", "MinFrostFreeDays"=>"0", "HedgeTolerance"=>"", "MoistureUse"=>"", "pH_Minimum"=>"0.00", "pH_Maximum"=>"0.00", "Min_PlantingDensity"=>"0", "Max_PlantingDensity"=>"0", "Precipitation_Minimum"=>"0", "Precipitation_Maximum"=>"0", "RootDepthMinimum"=>"0", "SalinityTolerance"=>"", "ShadeTolerance"=>"", "TemperatureMinimum"=>"0", "BloomPeriod"=>"", "CommercialAvailability"=>"", "FruitSeedPeriodBegin"=>"", "FruitSeedPeriodEnd"=>"", "Propogated_by_BareRoot"=>"", "Propogated_by_Bulbs"=>"", "Propogated_by_Container"=>"", "Propogated_by_Corms"=>"", "Propogated_by_Cuttings"=>"", "Propogated_by_Seed"=>"", "Propogated_by_Sod"=>"", "Propogated_by_Sprigs"=>"", "Propogated_by_Tubers"=>"", "Seeds_per_Pound"=>"0", "SeedSpreadRate"=>"", "SeedlingVigor"=>""}, "commit"=>"Update", "id"=>"2937"}
Redirected to https://www.betydb.org/species/2937/edit
Completed 302 Found in 9ms

Started GET "/species/2937/edit" for 128.174.125.237 at 2014-09-03 10:54:41 -0500
  Processing by SpeciesController#edit as HTML
  Parameters: {"id"=>"2937"}
Rendered species/_edit_pfts_species.html.erb (12.7ms)
Rendered feedback/_fbtab.html.erb (3.7ms)
Rendered species/edit.html.erb within layouts/application (288.8ms)
Completed 200 OK in 292ms (Views: 288.1ms | ActiveRecord: 3.8ms)

Via psql command line

  1. update species set spcd = 'SASA21', updated_at = now() where id = 2937;
  2. gives error:

    ERROR: invalid input syntax for integer: "SASA21" LINE 1: update species set spcd = 'SASA21', updated_at = now() where...

gsrohde commented 10 years ago

I think you want to be updating Symbol or AcceptedSymbol, not spcd. I don't remember what spcd is, but it must be an integer. (We should have comments in our database having to do with the semantics of the data, but I think at present these are mostly confined to the traits and the yields tables.)