Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .whitesource
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
##########################################################
#### WhiteSource "Bolt for Github" configuration file ####
##########################################################

# Configuration #
#---------------#
ws.repo.scan=true
vulnerable.check.run.conclusion.level=failure
26 changes: 25 additions & 1 deletion src/SQLite.Net/SQLiteConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1477,9 +1477,33 @@ public int Insert(object obj, string extra, Type objType)
}
}

bool usePkValue = false;
if (map.PK != null && map.PK.IsAutoInc)
{
var prop = objType.GetRuntimeProperty(map.PK.PropertyName);
if (prop != null)
{
var val = prop.GetValue(obj);
if (val != null && val.ToString() != "0")
{
usePkValue = true;
}
}
}

var replacing = string.Compare(extra, "OR REPLACE", StringComparison.OrdinalIgnoreCase) == 0;

var cols = replacing ? map.Columns : map.InsertColumns;
TableMapping.Column[] cols;

if (usePkValue)
{
cols = replacing ? map.Columns : map.InsertColumnsWithPk;
}
else
{
cols = replacing ? map.Columns : map.InsertColumns;
}

var vals = new object[cols.Length];
for (var i = 0; i < vals.Length; i++)
{
Expand Down
7 changes: 7 additions & 0 deletions src/SQLite.Net/TableMapping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@ public Column[] InsertColumns
{
get { return _insertColumns ?? (_insertColumns = Columns.Where(c => !c.IsAutoInc).ToArray()); }
}

[PublicAPI]
public Column[] InsertColumnsWithPk
{
get { return _insertColumns ?? (_insertColumns = Columns.ToArray()); }
}


[PublicAPI]
public void SetAutoIncPK(object obj, long id)
Expand Down