Database woes

Post Reply
user
Posts: 3
Joined: Wed May 14, 2014 6:19 am

Database woes

Post by user »

I am having trouble adding entries to a sheet in a db via both db:merge_unique and db:add and I am not sure why.

Originally it was throwing an error stating that UNIQUE was likely being violated, but as you can see it should have handling for that, not to mention the database is currently empty! Looking on the forums I saw that someone had a similar problem and the solution was downloading the most recent DB.lua, so I did that, and now it just silently fails to add entries (no error thrown).

Sample entry:
Code: [show] | [select all] lua
{
  targeted2 = "\"Damn you!\" Person swears at you.",
  type = "general",
  untargeted1 = "\"Damn it!\" you swear in frustration.",
  targeted1 = "\"Damn you!\" you swear at Iosai.",
  targeted3 = "\"Damn you!\" Person swears at Iosai.",
  pose = 0,
  command = "damn",
  pose3 = "empty",
  untargeted3 = "\"Damn it!\" Person swears in frustration.",
  targetted = 0
}
sheet schema: (not whole schema because there are multiple sheets)
Code: [show] | [select all] lua
		emotes = {
			command = "",
			type = "",
			pose = 0,
			targeted = 0,
			pose3 = "",
			targeted_pose = "",
			untargeted1 = "",
			untargeted3 = "",
			targeted1 = "",
			targeted2 = "",
			targeted3 = "",
			_unique = {"command"},
			_index = {"targeted3","targeted1","untargeted1","untargeted3","targeted2","pose3"},
			_violations = "REPLACE"
		}
Edit: It seems that display(ath.db.emotes) shows:
Code: [show] | [select all] lua
{
  _sht_name = "emotes",
  command = {
    database = "athref",
    type = "string",
    name = "command",
    sheet = "emotes"
  },
  _db_name = "athref"
}
I think it should be showing every column, though.

user
Posts: 3
Joined: Wed May 14, 2014 6:19 am

Re: Database woes

Post by user »

So, I did some more testing, and while unable to find a solution, I have found an odd workaround:
By doing db:merge_unique(refdb, {{command = "hi", targeted1 = "foo"}}) it will add the entry to the database. I then do the same thing for every field in the schema (eg {{command = "hi", targeted2 = "bar"}}) and by doing that it for each field, it will complete the entry.

No idea why it can't just accept the full entry at once though.

User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: Database woes

Post by Vadi »

Yeah, db:merge_unique takes in many records at once, so you use two tables (if you've just got one result).

Post Reply