Database.log "error"

ExpiredReign

Deity
Joined
Jan 3, 2013
Messages
2,450
Location
Tasmania
I'm not really sure where this should go.
It is a vanilla related topic not connected to any mod. Also it is more of a technical issue, but not really a modification problem.
Just a query.

Every game I play the database.log, regardless of the mods, or lack of, I have loaded has this as the first lines:

Code:
[94563.640] columns StrategicViewType, TileType are not unique
[94563.640] While executing - 'INSERT INTO ArtDefine_StrategicView(StrategicViewType, TileType, Asset) VALUES(?,?,?)'
[94642.046] columns StrategicViewType, TileType are not unique
[94642.046] While executing - 'INSERT INTO ArtDefine_StrategicView(StrategicViewType, TileType, Asset) VALUES(?,?,?)'
[94657.475]

Now I have done some research and found that, despite my initial thought, this is not a result of there being 2 Primary keys in this table (apparently that is fine if they combine to form 1 key) as is the case with this table.
Firaxis has defined the ArtDefine_StrategicView table this way:

Code:
CREATE TABLE ArtDefine_StrategicView("StrategicViewType" TEXT,
		 "TileType" TEXT NOT NULL,
		 "Asset" TEXT NOT NULL,
		 PRIMARY KEY("StrategicViewType", "TileType"));

thus 2 Primary Keys.

However, since the log keeps on flagging these as 'not unique', what is the reason for the code not specifying them as unique thusly:

Code:
CREATE TABLE ArtDefine_StrategicView("StrategicViewType" TEXT,
		 "TileType" TEXT NOT NULL,
		 "Asset" TEXT NOT NULL,
		 PRIMARY KEY("StrategicViewType", "TileType"),
                 UNIQUE("StrategicViewType", "TileType"));

Is this something that should be "fixed" or am I just being overly picky and pedantic?

Just another question in my learning the code.:D

Moderator Action: Moved to C&C where you should find a better response to you questions. Best of luck.
 
@nutty

Hmm.. This seems to differ greatly to this from SO.

There they say UNIQUE keys are defined, not simply a state that is associated with being PRIMARY.







PS. Thanks to the Moderators for the move. ;)
 
Huh.:confused:

So, are you saying they SHOULD have defined them as UNIQUE in their CREATE TABLE code?

I see no other INSERTs into this table anywhere.

I'm only trying to develop good coding habits, and everytime I see things like this from people/companies, that I imagine know what they are doing, I get confused.

As I said in the OP, am I just being pedantic, or is this a case of an error being left alone because it doesn't 'break' anything? (except my mind :crazyeye:)
 
No, a primary MUST be unique, or it wouldn't make any sense, so there's no need to try to specify it as such. I'm not sure where those inserts occur from the many places they could occur in the game code and data files, but it doesn't seem worth the effort of tracking it down.
 
Thanks @Nutty.

Actually with a good search tool, I use Sublime Text's find in files command, it is pretty easy to see any code that is related to this table.
But, if I was asking in an effort to fix this problem, which I'm not. I agree, it would be pointless. Firaxis can do what it wants with its code.

I was simply asking to try and understand why certain error messages can be safely ignored and others can't. Yeah I know, to those with programming skills it makes perfect sense. However all I have to go on is some good books, various sources on the web and the good people here in this forum, like yourself.

So, thank you very much. I appreciate your comments to this question.

Well I guess I shall leave it as is now and keep on trying to learn by chasing other points that pique my interest.

Thanks again.
 
I was simply asking to try and understand why certain error messages can be safely ignored and others can't.

You can ignore any error messages that aren't generated by mods, ie those Firaxis left in, on the assumptions that a) if they passed QA they can't be that detrimental to the game and b) there is probably nothing you can do about them anyway.

To ascertain which errors are not mod related, see the second half of post #1 in the "How to enable logging" thread
 
@whoward69

Thank you, but as my OP showed, I am fully aware that this is not mod related.
I have been following your 'Tutorials' and other mod related posts ever since I joined this forum, and have already learned much. Thank you.

It was, as I said, just an exercise in learning.

I figured, what could be wrong in examining how "professionals" do it?
Apparently "professionals" can be pretty sloppy if it doesn't mess up the end product.
 
Top Bottom