Commit 466a5704 authored by Benoît Minisini's avatar Benoît Minisini

Connection.GetTemplate() and Connection.ApplyTemplate() now take tables...

Connection.GetTemplate() and Connection.ApplyTemplate() now take tables without primary key into account correctly.

[GB.DB]
* BUG: Connection.GetTemplate() and Connection.ApplyTemplate() now take tables without primary key into account correctly.
parent c0eab6b4
......@@ -179,7 +179,10 @@ BEGIN_PROPERTY(CTABLE_primary_key)
field = *((char **)GB.Array.Get(primary, i));
if (!CFIELD_exist(THIS, field))
{
GB.Error("Unknown field: &1", field);
if (!field)
GB.Error("Void field name");
else
GB.Error("Unknown field: &1", field);
return;
}
}
......
[Component]
Key=gb.db
Version=3.12.0
Version=3.12.90
# Gambas Project File 3.0
Title=gb.db
Startup=Main
Version=3.12.0
Version=3.12.90
VersionFile=1
Component=gb.db
TabSize=2
......
......@@ -24,6 +24,7 @@ Public Sub ApplyTemplate(Template As String)
Dim iLength As Integer
Dim sErr As String
Dim sColl As String
Dim aKey As String[]
hFile = Open String Template
......@@ -120,7 +121,9 @@ CREATE_TABLE:
Next
'Print "primary key: "; cTable["PrimaryKey"].Join(",")
hTable.PrimaryKey = cTable["PrimaryKey"]
aKey = cTable["PrimaryKey"]
If aKey.Count = 1 And If aKey[0] = "" Then aKey.Clear
If aKey.Count Then hTable.PrimaryKey = cTable["PrimaryKey"]
hTable.Update
For Each cIndex In cTable["Indexes"]
......@@ -141,6 +144,7 @@ Public Sub GetTemplate() As String
Dim hField As Field
Dim hIndex As Index
Dim sTemplate As String
Dim aKey As String[]
hFile = Open String For Write
......@@ -160,7 +164,8 @@ Public Sub GetTemplate() As String
Print #hFile, "{ Table"
Print #hFile, " Name="; Quote(hTable.Name)
If hTable.Type Then Print #hFile, " Type="; Quote(hTable.Type)
Print #hFile, " PrimaryKey=[\""; hTable.PrimaryKey.Join("\",\""); "\"]"
aKey = hTable.PrimaryKey
If aKey.Count Then Print #hFile, " PrimaryKey=[\""; aKey.Join("\",\""); "\"]"
For Each hField In hTable.Fields
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment