From d2a285448c39fbe1c6b29e5a86b9da0eb7221c3d Mon Sep 17 00:00:00 2001 From: perrein Date: Thu, 10 Sep 2015 09:06:01 +0200 Subject: [PATCH 1/3] Autoincrement not automatic if an ID != 0 is set ! --- src/SQLite.Net/SQLiteConnection.cs | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/SQLite.Net/SQLiteConnection.cs b/src/SQLite.Net/SQLiteConnection.cs index bb59b273e..960af80e1 100644 --- a/src/SQLite.Net/SQLiteConnection.cs +++ b/src/SQLite.Net/SQLiteConnection.cs @@ -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++) { From a5650929552cd942ae05dff7f3a32f52c70bfdba Mon Sep 17 00:00:00 2001 From: perrein Date: Mon, 14 Sep 2015 11:40:09 +0200 Subject: [PATCH 2/3] Missing... --- src/SQLite.Net/TableMapping.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/SQLite.Net/TableMapping.cs b/src/SQLite.Net/TableMapping.cs index c14a5081b..46a14b0b4 100644 --- a/src/SQLite.Net/TableMapping.cs +++ b/src/SQLite.Net/TableMapping.cs @@ -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) From f01d291dd37491a10a78e0fb1f61cc40dc060121 Mon Sep 17 00:00:00 2001 From: "whitesource-bolt-for-github[bot]" Date: Wed, 6 Feb 2019 17:26:20 +0000 Subject: [PATCH 3/3] Initial WhiteSource configuration file --- .whitesource | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .whitesource diff --git a/.whitesource b/.whitesource new file mode 100644 index 000000000..9b3d393d5 --- /dev/null +++ b/.whitesource @@ -0,0 +1,8 @@ +########################################################## +#### WhiteSource "Bolt for Github" configuration file #### +########################################################## + +# Configuration # +#---------------# +ws.repo.scan=true +vulnerable.check.run.conclusion.level=failure