Skip to content

armgit / Vvveb

Public Imported from GitHub
0

Powerful and easy to use cms to build websites, blogs or ecommerce stores.

Added RETURNING for INSERT queries to return last insert id, changed json generation with CONCAT to json_agg and json_build_object, fixed menu and categories queries, removed redundant ; from @FILTER

givanz37e300ebd054
diff --git a/admin/sql/pgsql/admin.sql b/admin/sql/pgsql/admin.sql
index 991100b..22661fd 100755
--- a/admin/sql/pgsql/admin.sql
+++ b/admin/sql/pgsql/admin.sql
@@ -116,18 +116,18 @@
CREATE PROCEDURE add(
IN admin ARRAY,
- OUT insert_id
+ OUT fetch_one
)
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:admin, admin);
+ @FILTER(:admin, admin)
INSERT INTO admin
( @KEYS(:admin) )
- VALUES ( :admin )
+ VALUES ( :admin ) RETURNING admin_id;
END
@@ -143,7 +143,7 @@
)
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:admin, admin);
+ @FILTER(:admin, admin)
UPDATE admin
diff --git a/admin/sql/pgsql/attribute.sql b/admin/sql/pgsql/attribute.sql
index f3a8e8e..6481c1f 100755
--- a/admin/sql/pgsql/attribute.sql
+++ b/admin/sql/pgsql/attribute.sql
@@ -13,7 +13,7 @@
)
BEGIN
-- attribute
- SELECT attribute_content.name, attribute_group_content.name as `group`, attribute.*
+ SELECT attribute_content.name, attribute_group_content.name as "group", attribute.*
@IF isset(:product_id)
THEN
,pa.value
@@ -83,22 +83,23 @@
PROCEDURE add(
IN attribute ARRAY,
+ OUT fetch_one,
OUT insert_id
)
BEGIN
-- allow only table fields and set defaults for missing values
- :attribute_data = @FILTER(:attribute, attribute);
+ :attribute_data = @FILTER(:attribute, attribute)
INSERT INTO attribute
( @KEYS(:attribute_data) )
- VALUES ( :attribute_data );
+ VALUES ( :attribute_data ) RETURNING attribute_id;
- :attribute_content = @FILTER(:attribute, attribute_content);
+ :attribute_content = @FILTER(:attribute, attribute_content)
INSERT INTO attribute_content
@@ -119,7 +120,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :attribute_data = @FILTER(:attribute, attribute);
+ :attribute_data = @FILTER(:attribute, attribute)
UPDATE attribute
@@ -128,7 +129,7 @@
WHERE attribute_id = :attribute_id;
-- allow only table fields and set defaults for missing values
- :attribute_content = @FILTER(:attribute, attribute_content);
+ :attribute_content = @FILTER(:attribute, attribute_content)
UPDATE attribute_content
diff --git a/admin/sql/pgsql/attribute_group.sql b/admin/sql/pgsql/attribute_group.sql
index 40da1b4..543c7f7 100755
--- a/admin/sql/pgsql/attribute_group.sql
+++ b/admin/sql/pgsql/attribute_group.sql
@@ -12,7 +12,7 @@
)
BEGIN
-- attribute_group
- SELECT attribute_group_content.name, attribute_group_content.name as `group`, attribute_group.*
+ SELECT attribute_group_content.name, attribute_group_content.name as "group", attribute_group.*
@IF isset(:product_id)
THEN
,pa.value
@@ -69,22 +69,23 @@
PROCEDURE add(
IN attribute_group ARRAY,
+ OUT fetch_one,
OUT insert_id
)
BEGIN
-- allow only table fields and set defaults for missing values
- :attribute_group_data = @FILTER(:attribute_group, attribute_group);
+ :attribute_group_data = @FILTER(:attribute_group, attribute_group)
INSERT INTO attribute_group
( @KEYS(:attribute_group_data) )
- VALUES ( :attribute_group_data );
+ VALUES ( :attribute_group_data ) RETURNING attribute_group_id;
- :attribute_group_content = @FILTER(:attribute_group, attribute_group_content);
+ :attribute_group_content = @FILTER(:attribute_group, attribute_group_content)
INSERT INTO attribute_group_content
@@ -105,7 +106,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :attribute_group_data = @FILTER(:attribute_group, attribute_group);
+ :attribute_group_data = @FILTER(:attribute_group, attribute_group)
UPDATE attribute_group
@@ -114,7 +115,7 @@
WHERE attribute_group_id = :attribute_group_id;
-- allow only table fields and set defaults for missing values
- :attribute_group_content = @FILTER(:attribute_group, attribute_group_content);
+ :attribute_group_content = @FILTER(:attribute_group, attribute_group_content)
UPDATE attribute_group_content
diff --git a/admin/sql/pgsql/category.sql b/admin/sql/pgsql/category.sql
index a560505..9ce0f2c 100755
--- a/admin/sql/pgsql/category.sql
+++ b/admin/sql/pgsql/category.sql
@@ -20,7 +20,7 @@
-- return array of categories for categories query
OUT fetch_all,
-- return categories count for count query
- OUT fetch_one,
+ OUT fetch_one
)
BEGIN
@@ -153,11 +153,11 @@
-- return array of categories for categories query
OUT fetch_all,
-- return categories count for count query
- OUT fetch_one,
+ OUT fetch_one
)
BEGIN
- SELECT DISTINCT categories.taxonomy_item_id, @taxonomy_item_id = categories.taxonomy_item_id, categories.*, tc.*, tc.content as content, categories.taxonomy_item_id as array_key
+ SELECT DISTINCT categories.taxonomy_item_id, categories.*, tc.*, tc.content as content, categories.taxonomy_item_id as array_key
@IF isset(:post_id)
THEN
@@ -165,11 +165,12 @@
END @IF
- ,(SELECT CONCAT('[', GROUP_CONCAT('{"post_id":"', pc.post_id, '","slug":"' , pc.slug,'","sort_order":"' , p.sort_order, '","name":"' , pc.name, '"}'), ']')
+ -- ,(SELECT CONCAT('[', GROUP_CONCAT('{"post_id":"', pc.post_id, '","slug":"' , pc.slug,'","sort_order":"' , p.sort_order, '","name":"' , pc.name, '"}'), ']')
+ ,(SELECT json_agg(json_build_object('post_id',pc.post_id,'slug',pc.slug,'slug',pc.slug,'sort_order',pc.sort_order,'name',pc.name))
FROM post_content pc
LEFT JOIN post p ON (pc.post_id = p.post_id)
- LEFT JOIN post_to_taxonomy_item ptt ON (ptt.taxonomy_item_id = @taxonomy_item_id AND ptt.post_id = p.post_id)
- WHERE ptt.taxonomy_item_id = @taxonomy_item_id ORDER by p.sort_order
+ LEFT JOIN post_to_taxonomy_item ptt ON (ptt.taxonomy_item_id = categories.taxonomy_item_id AND ptt.post_id = p.post_id)
+ WHERE ptt.taxonomy_item_id = categories.taxonomy_item_id ORDER by p.sort_order
) AS posts
FROM taxonomy_item AS categories
@@ -246,7 +247,7 @@
IN post_type CHAR,
IN type CHAR,
IN slug CHAR,
- OUT fetch_row,
+ OUT fetch_row
)
BEGIN
-- taxonomy_item
@@ -330,7 +331,7 @@
IN language_id INT,
IN post_type CHAR,
IN slug CHAR,
- OUT fetch_row,
+ OUT fetch_row
)
BEGIN
@@ -408,7 +409,7 @@
DELETE FROM taxonomy_item_content WHERE taxonomy_item_id = :taxonomy_item_id;
- @FILTER(:taxonomy_item_content, taxonomy_item_content);
+ @FILTER(:taxonomy_item_content, taxonomy_item_content)
@EACH(:taxonomy_item_content)
INSERT INTO taxonomy_item_content
@@ -421,7 +422,7 @@
-- SELECT * FROM taxonomy_item_option WHERE taxonomy_item_id = :taxonomy_item_id;
-- allow only table fields and set defaults for missing values
- @FILTER(:taxonomy_item, taxonomy_item);
+ @FILTER(:taxonomy_item, taxonomy_item)
UPDATE taxonomy_item
@@ -438,30 +439,23 @@
IN taxonomy_item ARRAY,
IN taxonomy_item_content ARRAY,
IN site_id INT,
+ OUT fetch_one,
OUT insert_id,
- OUT insert_id,
- OUT insert_id,
+ OUT insert_id
)
BEGIN
-- allow only table fields and set defaults for missing values
- :taxonomy_item = @FILTER(:taxonomy_item, taxonomy_item);
- :taxonomy_item_content = @FILTER(:taxonomy_item_content, taxonomy_item_content);
+ :taxonomy_item = @FILTER(:taxonomy_item, taxonomy_item)
+ :taxonomy_item_content = @FILTER(:taxonomy_item_content, taxonomy_item_content)
INSERT INTO taxonomy_item
( @KEYS(:taxonomy_item) )
- VALUES ( :taxonomy_item );
+ VALUES ( :taxonomy_item ) RETURNING taxonomy_item_id;
- -- SET :taxonomy_item_content.taxonomy_item_id = last_insert_id;
- -- SET @taxonomy_item_id = LAST_INSERT_ID();
-
- -- UPDATE taxonomy_item SET image = :image WHERE taxonomy_item_id = :taxonomy_item_id;
-
- -- :taxonomy_item = @FILTER(:taxonomy_item, taxonomy_item);
-
INSERT INTO taxonomy_item_content
( taxonomy_item_id, @KEYS(:taxonomy_item_content) )
@@ -475,8 +469,6 @@
VALUES ( @result.taxonomy_item, :site_id );
-
- SELECT @taxonomy_item_id as taxonomy_item_id;
END
@@ -497,22 +489,22 @@
-- return array of categories for categories query
OUT fetch_all,
-- return categories count for count query
- OUT fetch_one,
+ OUT fetch_one
)
BEGIN
SELECT *,
(
SELECT
- CONCAT('[', GROUP_CONCAT(
- '{"language_id":"', tc.language_id,
- '","name":"' , tc.name,
- '","slug":"' , tc.slug,
- '","content":"' , tc.content,
- '","meta_title":"' , tc.meta_title,
- '","meta_description":"' , tc.meta_description,
- '","meta_keywords":"' , tc.meta_keywords, '"}'), ']')
-
+ json_agg(json_build_object(
+ 'language_id', tc.language_id,
+ 'name' , tc.name,
+ 'slug' , tc.slug,
+ 'content' , tc.content,
+ 'meta_title' , tc.meta_title,
+ 'meta_description' , tc.meta_description,
+ 'meta_keywords' , tc.meta_keywords) )
+
FROM taxonomy_item_content as tc
WHERE
tc.taxonomy_item_id = categories.taxonomy_item_id GROUP BY tc.taxonomy_item_id
@@ -581,7 +573,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :taxonomy_item_content_data = @FILTER(:taxonomy_item.taxonomy_item_content, taxonomy_item_content);
+ :taxonomy_item_content_data = @FILTER(:taxonomy_item.taxonomy_item_content, taxonomy_item_content)
@EACH(:taxonomy_item_content_data)
INSERT INTO taxonomy_item_content
@@ -589,10 +581,11 @@
( @KEYS(:each), taxonomy_item_id)
VALUES ( :each, :taxonomy_item_id)
- ON DUPLICATE KEY UPDATE @LIST(:each);
+ ON CONFLICT("taxonomy_item_id","language_id")
+ DO UPDATE SET @LIST(:each);
-- allow only table fields and set defaults for missing values
- @FILTER(:taxonomy_item, taxonomy_item);
+ @FILTER(:taxonomy_item, taxonomy_item)
UPDATE taxonomy_item
@@ -608,19 +601,20 @@
CREATE PROCEDURE addTaxonomyItem(
IN taxonomy_item ARRAY,
IN site_id INT,
+ OUT fetch_one,
OUT insert_id
)
BEGIN
-- allow only table fields and set defaults for missing values
- :taxonomy_item_content_data = @FILTER(:taxonomy_item.taxonomy_item_content, taxonomy_item_content);
- :taxonomy_item_data = @FILTER(:taxonomy_item, taxonomy_item);
+ :taxonomy_item_content_data = @FILTER(:taxonomy_item.taxonomy_item_content, taxonomy_item_content)
+ :taxonomy_item_data = @FILTER(:taxonomy_item, taxonomy_item)
INSERT INTO taxonomy_item
( @KEYS(:taxonomy_item_data) )
- VALUES ( :taxonomy_item_data );
+ VALUES ( :taxonomy_item_data ) RETURNING taxonomy_item_id;
INSERT INTO taxonomy_to_site
@@ -636,8 +630,6 @@
VALUES ( @result.taxonomy_item, :each );
-
- SELECT @taxonomy_item as taxonomy_item;
END
@@ -649,7 +641,7 @@
)
BEGIN
- :taxonomy_item_data = @FILTER(:taxonomy_items, taxonomy_item);
+ :taxonomy_item_data = @FILTER(:taxonomy_items, taxonomy_item)
@EACH(:taxonomy_item_data)
UPDATE taxonomy_item
diff --git a/admin/sql/pgsql/comment.sql b/admin/sql/pgsql/comment.sql
index 72444fa..e5a6b76 100755
--- a/admin/sql/pgsql/comment.sql
+++ b/admin/sql/pgsql/comment.sql
@@ -23,9 +23,9 @@
)
BEGIN
- SELECT user.*, comment.*, comment_id as array_key
+ SELECT "user".*, comment.*, comment_id as array_key
FROM comment AS comment
- LEFT JOIN user ON (comment.user_id = comment.user_id)
+ LEFT JOIN "user" ON (comment.user_id = comment.user_id)
@IF isset(:post_title) AND :post_title
THEN
@@ -110,18 +110,18 @@
CREATE PROCEDURE add(
IN comment ARRAY,
- OUT insert_id
+ OUT fetch_one
)
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:comment, comment);
+ @FILTER(:comment, comment)
INSERT INTO comment
( @KEYS(:comment) )
- VALUES ( :comment )
+ VALUES ( :comment ) RETURNING comment_id;
END
@@ -134,7 +134,7 @@
)
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:comment, comment);
+ @FILTER(:comment, comment)
UPDATE comment
diff --git a/admin/sql/pgsql/country.sql b/admin/sql/pgsql/country.sql
index 5a71aca..be1a67b 100755
--- a/admin/sql/pgsql/country.sql
+++ b/admin/sql/pgsql/country.sql
@@ -59,19 +59,19 @@
PROCEDURE add(
IN country ARRAY,
IN language_id INT,
- OUT insert_id
+ OUT fetch_one
)
BEGIN
-- allow only table fields and set defaults for missing values
- :country_data = @FILTER(:country, country);
+ :country_data = @FILTER(:country, country)
INSERT INTO country
( @KEYS(:country_data) )
- VALUES ( :country_data );
+ VALUES ( :country_data ) RETURNING country_id;
END
@@ -85,7 +85,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:country, country);
+ @FILTER(:country, country)
UPDATE country
diff --git a/admin/sql/pgsql/coupon.sql b/admin/sql/pgsql/coupon.sql
index bfbeaff..f00ec5a 100755
--- a/admin/sql/pgsql/coupon.sql
+++ b/admin/sql/pgsql/coupon.sql
@@ -67,19 +67,19 @@
PROCEDURE add(
IN coupon ARRAY,
- OUT insert_id
+ OUT fetch_one
)
BEGIN
-- allow only table fields and set defaults for missing values
- :coupon_data = @FILTER(:coupon, coupon);
+ :coupon_data = @FILTER(:coupon, coupon)
INSERT INTO coupon
( @KEYS(:coupon_data) )
- VALUES ( :coupon_data );
+ VALUES ( :coupon_data ) RETURNING coupon_id;
END
@@ -93,7 +93,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:coupon, coupon);
+ @FILTER(:coupon, coupon)
UPDATE coupon
diff --git a/admin/sql/pgsql/currency.sql b/admin/sql/pgsql/currency.sql
index 553e82b..0597cd1 100755
--- a/admin/sql/pgsql/currency.sql
+++ b/admin/sql/pgsql/currency.sql
@@ -43,19 +43,19 @@
PROCEDURE add(
IN currency ARRAY,
- OUT insert_id
+ OUT fetch_one
)
BEGIN
-- allow only table fields and set defaults for missing values
- :currency_data = @FILTER(:currency, currency);
+ :currency_data = @FILTER(:currency, currency)
INSERT INTO currency
( @KEYS(:currency_data) )
- VALUES ( :currency_data );
+ VALUES ( :currency_data ) RETURNING currency_id;
END
@@ -68,7 +68,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:currency, currency);
+ @FILTER(:currency, currency)
UPDATE currency
diff --git a/admin/sql/pgsql/digital_asset.sql b/admin/sql/pgsql/digital_asset.sql
index 9ce0551..f7bd7ac 100755
--- a/admin/sql/pgsql/digital_asset.sql
+++ b/admin/sql/pgsql/digital_asset.sql
@@ -53,22 +53,23 @@
PROCEDURE add(
IN digital_asset ARRAY,
+ OUT fetch_one,
OUT insert_id
)
BEGIN
-- allow only table fields and set defaults for missing values
- :digital_asset_data = @FILTER(:digital_asset, digital_asset);
+ :digital_asset_data = @FILTER(:digital_asset, digital_asset)
INSERT INTO digital_asset
( @KEYS(:digital_asset_data) )
- VALUES ( :digital_asset_data );
+ VALUES ( :digital_asset_data ) RETURNING digital_asset_id;
- :digital_asset_content = @FILTER(:digital_asset, digital_asset_content);
+ :digital_asset_content = @FILTER(:digital_asset, digital_asset_content)
INSERT INTO digital_asset_content
@@ -89,7 +90,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :digital_asset_data = @FILTER(:digital_asset, digital_asset);
+ :digital_asset_data = @FILTER(:digital_asset, digital_asset)
UPDATE digital_asset
@@ -98,7 +99,7 @@
WHERE digital_asset_id = :digital_asset_id;
-- allow only table fields and set defaults for missing values
- :digital_asset_content = @FILTER(:digital_asset, digital_asset_content);
+ :digital_asset_content = @FILTER(:digital_asset, digital_asset_content)
UPDATE digital_asset_content
diff --git a/admin/sql/pgsql/field_group.sql b/admin/sql/pgsql/field_group.sql
index 88290d8..1593f5b 100755
--- a/admin/sql/pgsql/field_group.sql
+++ b/admin/sql/pgsql/field_group.sql
@@ -58,23 +58,23 @@
PROCEDURE add(
IN field_group ARRAY,
IN language_id INT,
- OUT insert_id
- OUT affected_rows
+ OUT fetch_one,
+ OUT affected_rows,
OUT insert_id
)
BEGIN
-- allow only table fields and set defaults for missing values
- :field_group_data = @FILTER(:field_group, field_group);
+ :field_group_data = @FILTER(:field_group, field_group)
INSERT INTO field_group
( @KEYS(:field_group_data) )
- VALUES ( :field_group_data);
+ VALUES ( :field_group_data) RETURNING field_group_id;
-- allow only table fields and set defaults for missing values
- :field_group_content_data = @FILTER(:field_group, field_group_content);
+ :field_group_content_data = @FILTER(:field_group, field_group_content)
INSERT INTO field_group_content
@@ -94,7 +94,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :field_group_data = @FILTER(:field_group, field_group);
+ :field_group_data = @FILTER(:field_group, field_group)
UPDATE field_group
@@ -103,7 +103,7 @@
WHERE field_group_id = :field_group_id;
-- allow only table fields and set defaults for missing values
- :field_group_content_data = @FILTER(:field_group, field_group_content);
+ :field_group_content_data = @FILTER(:field_group, field_group_content)
UPDATE field_group_content
diff --git a/admin/sql/pgsql/language.sql b/admin/sql/pgsql/language.sql
index 2c5ebae..773ddd8 100755
--- a/admin/sql/pgsql/language.sql
+++ b/admin/sql/pgsql/language.sql
@@ -65,19 +65,19 @@
PROCEDURE add(
IN language ARRAY,
- OUT insert_id
+ OUT fetch_one
)
BEGIN
-- allow only table fields and set defaults for missing values
- :language_data = @FILTER(:language, language);
+ :language_data = @FILTER(:language, language)
INSERT INTO language
( @KEYS(:language_data) )
- VALUES ( :language_data );
+ VALUES ( :language_data ) RETURNING language_id;
END
@@ -103,7 +103,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:language, language);
+ @FILTER(:language, language)
UPDATE language
diff --git a/admin/sql/pgsql/length_type.sql b/admin/sql/pgsql/length_type.sql
index 56e44d2..876a414 100755
--- a/admin/sql/pgsql/length_type.sql
+++ b/admin/sql/pgsql/length_type.sql
@@ -58,23 +58,22 @@
PROCEDURE add(
IN length_type ARRAY,
IN language_id INT,
- OUT insert_id
- OUT affected_rows
+ OUT fetch_one
OUT insert_id
)
BEGIN
-- allow only table fields and set defaults for missing values
- :length_type_data = @FILTER(:length_type, length_type);
+ :length_type_data = @FILTER(:length_type, length_type)
INSERT INTO length_type
( @KEYS(:length_type_data) )
- VALUES ( :length_type_data);
+ VALUES ( :length_type_data) RETURNING length_type_id;
-- allow only table fields and set defaults for missing values
- :length_type_content_data = @FILTER(:length_type, length_type_content);
+ :length_type_content_data = @FILTER(:length_type, length_type_content)
INSERT INTO length_type_content
@@ -94,7 +93,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :length_type_data = @FILTER(:length_type, length_type);
+ :length_type_data = @FILTER(:length_type, length_type)
UPDATE length_type
@@ -103,7 +102,7 @@
WHERE length_type_id = :length_type_id;
-- allow only table fields and set defaults for missing values
- :length_type_content_data = @FILTER(:length_type, length_type_content);
+ :length_type_content_data = @FILTER(:length_type, length_type_content)
UPDATE length_type_content
diff --git a/admin/sql/pgsql/manufacturer.sql b/admin/sql/pgsql/manufacturer.sql
index 663e8c9..6db8d93 100755
--- a/admin/sql/pgsql/manufacturer.sql
+++ b/admin/sql/pgsql/manufacturer.sql
@@ -50,7 +50,7 @@
-- SELECT * FROM manufacturer_option WHERE manufacturer_id = :manufacturer_id;
-- allow only table fields and set defaults for missing values
- @FILTER(:manufacturer, manufacturer);
+ @FILTER(:manufacturer, manufacturer)
UPDATE manufacturer
@@ -65,18 +65,19 @@
CREATE PROCEDURE add(
IN manufacturer ARRAY,
+ OUT fetch_one,
OUT insert_id
)
BEGIN
-- allow only table fields and set defaults for missing values
- :manufacturer = @FILTER(:manufacturer, manufacturer);
+ :manufacturer = @FILTER(:manufacturer, manufacturer)
INSERT INTO manufacturer
( @KEYS(:manufacturer) )
- VALUES ( :manufacturer );
+ VALUES ( :manufacturer ) RETURNING manufacturer_id;
INSERT INTO manufacturer_to_site
diff --git a/admin/sql/pgsql/menu.sql b/admin/sql/pgsql/menu.sql
index 02f64da..b610652 100755
--- a/admin/sql/pgsql/menu.sql
+++ b/admin/sql/pgsql/menu.sql
@@ -10,7 +10,7 @@
IN site_id INT,
-- return menus count for count query
- OUT fetch_row,
+ OUT fetch_row
)
BEGIN
@@ -34,7 +34,7 @@
IN name CHAR,
-- return menus count for count query
- OUT affected_rows,
+ OUT affected_rows
)
BEGIN
@@ -53,16 +53,16 @@
IN menu ARRAY,
-- return menus count for count query
- OUT insert_id,
+ OUT fetch_one
)
BEGIN
- @FILTER(:menu, menu);
+ @FILTER(:menu, menu)
INSERT INTO menu
( @KEYS(:menu) )
- VALUES ( :menu );
+ VALUES ( :menu ) RETURNING menu_id;
END
@@ -146,7 +146,7 @@
-- return array of menus for menus query
OUT fetch_all,
-- return menus count for count query
- -- OUT fetch_one,
+ -- OUT fetch_one
)
BEGIN
@@ -266,7 +266,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :menu_item_content_data = @FILTER(:menu_item.menu_item_content, menu_item_content);
+ :menu_item_content_data = @FILTER(:menu_item.menu_item_content, menu_item_content)
@EACH(:menu_item_content_data)
INSERT INTO menu_item_content
@@ -274,10 +274,10 @@
( @KEYS(:each), menu_item_id)
VALUES ( :each, :menu_item_id)
- ON DUPLICATE KEY UPDATE @LIST(:each);
+ ON CONFLICT ("menu_item_id","language_id") DO UPDATE SET @LIST(:each);
-- allow only table fields and set defaults for missing values
- @FILTER(:menu_item, menu_item);
+ @FILTER(:menu_item, menu_item)
UPDATE menu_item
@@ -292,19 +292,20 @@
CREATE PROCEDURE addMenuItem(
IN menu_item ARRAY,
+ OUT fetch_one,
OUT insert_id
)
BEGIN
-- allow only table fields and set defaults for missing values
- :menu_item_content_data = @FILTER(:menu_item.menu_item_content, menu_item_content);
- :menu_item_data = @FILTER(:menu_item, menu_item);
+ :menu_item_content_data = @FILTER(:menu_item.menu_item_content, menu_item_content)
+ :menu_item_data = @FILTER(:menu_item, menu_item)
INSERT INTO menu_item
( @KEYS(:menu_item_data) )
- VALUES ( :menu_item_data );
+ VALUES ( :menu_item_data ) RETURNING menu_item_id;
@EACH(:menu_item_content_data)
@@ -314,8 +315,6 @@
VALUES ( @result.menu_item, :each );
-
- SELECT @menu_item as menu_item;
END
-- Reorder menu items
@@ -326,7 +325,7 @@
)
BEGIN
- :menu_item_data = @FILTER(:menu_items, menu_item);
+ :menu_item_data = @FILTER(:menu_items, menu_item)
@EACH(:menu_item_data)
UPDATE menu_item
@@ -337,9 +336,9 @@
END
- -- Delete menu item
+ -- Delete menu item recursive
- CREATE PROCEDURE deleteMenuItem(
+ CREATE PROCEDURE deleteMenuItemRecursive(
IN menu_item_id INT,
OUT affected_rows,
OUT affected_rows,
@@ -381,3 +380,21 @@
SELECT menu_item_id FROM tree);
END
+
+ -- Delete menu item
+
+ CREATE PROCEDURE deleteMenuItem(
+ IN menu_item_id INT,
+ OUT affected_rows,
+ OUT affected_rows
+ )
+ BEGIN
+
+ -- does not delete grand child menu items
+ DELETE FROM menu_item_content WHERE menu_item_id IN (SELECT menu_item_id FROM menu_item WHERE parent_id = :menu_item_id);
+ DELETE FROM menu_item_content WHERE menu_item_id = :menu_item_id;
+
+ DELETE FROM menu_item WHERE menu_item_id IN (SELECT menu_item_id FROM menu_item WHERE parent_id = :menu_item_id);
+ DELETE FROM menu_item WHERE menu_item_id = :menu_item_id;
+
+ END
diff --git a/admin/sql/pgsql/option.sql b/admin/sql/pgsql/option.sql
index 3f03b12..9620131 100644
--- a/admin/sql/pgsql/option.sql
+++ b/admin/sql/pgsql/option.sql
@@ -53,22 +53,23 @@
PROCEDURE add(
IN option ARRAY,
+ OUT fetch_one,
OUT insert_id
)
BEGIN
-- allow only table fields and set defaults for missing values
- :option_data = @FILTER(:option, option);
+ :option_data = @FILTER(:option, option)
INSERT INTO "option"
( @KEYS(:option_data) )
- VALUES ( :option_data );
+ VALUES ( :option_data ) RETURNING option_id;
- :option_content = @FILTER(:option, option_content);
+ :option_content = @FILTER(:option, option_content)
INSERT INTO option_content
@@ -89,7 +90,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :option_data = @FILTER(:option, option);
+ :option_data = @FILTER(:option, option)
UPDATE "option"
@@ -98,7 +99,7 @@
WHERE option_id = :option_id;
-- allow only table fields and set defaults for missing values
- :option_content = @FILTER(:option, option_content);
+ :option_content = @FILTER(:option, option_content)
UPDATE option_content
diff --git a/admin/sql/pgsql/option_value.sql b/admin/sql/pgsql/option_value.sql
index 38c3f89..e2fce4f 100644
--- a/admin/sql/pgsql/option_value.sql
+++ b/admin/sql/pgsql/option_value.sql
@@ -60,22 +60,23 @@
PROCEDURE add(
IN option_value ARRAY,
+ OUT fetch_one,
OUT insert_id
)
BEGIN
-- allow only table fields and set defaults for missing values
- :option_value_data = @FILTER(:option_value, option_value);
+ :option_value_data = @FILTER(:option_value, option_value)
INSERT INTO option_value
( @KEYS(:option_value_data) )
- VALUES ( :option_value_data );
+ VALUES ( :option_value_data ) RETURNING option_value_id;
- :option_value_content = @FILTER(:option_value, option_value_content);
+ :option_value_content = @FILTER(:option_value, option_value_content)
INSERT INTO option_value_content
@@ -96,7 +97,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :option_value_data = @FILTER(:option_value, option_value);
+ :option_value_data = @FILTER(:option_value, option_value)
UPDATE option_value
@@ -105,7 +106,7 @@
WHERE option_value_id = :option_value_id;
-- allow only table fields and set defaults for missing values
- :option_value_content = @FILTER(:option_value, option_value_content);
+ :option_value_content = @FILTER(:option_value, option_value_content)
UPDATE option_value_content
diff --git a/admin/sql/pgsql/order.sql b/admin/sql/pgsql/order.sql
index 8ea056c..d764b75 100755
--- a/admin/sql/pgsql/order.sql
+++ b/admin/sql/pgsql/order.sql
@@ -260,22 +260,23 @@
CREATE PROCEDURE add(
IN order ARRAY,
- OUT insert_id,
- OUT insert_id,
- OUT insert_id,
- OUT insert_id
+ OUT fetch_one,
+ OUT fetch_one,
+ OUT fetch_one,
+ OUT fetch_one
)
BEGIN
- :products = @FILTER(:"order".products, order_product, false, true);
- :totals = @FILTER(:"order".totals, order_total, false, true);
- @FILTER(:order, order);
+ :products = @FILTER(:order.products, order_product, false, true)
+ :totals = @FILTER(:order.totals, order_total, false, true)
+
+ @FILTER(:order, order)
INSERT INTO "order"
( @KEYS(:order) )
- VALUES ( :order );
+ VALUES ( :order ) RETURNING order_id;
-- insert order products
@EACH(:products)
@@ -287,7 +288,7 @@
@EACH(:product_options)
INSERT INTO order_product_option
( order_id, @KEYS(:each) )
- VALUES ( @result.order, 0, :each );
+ VALUES ( @result.order, :each );
-- insert order products
@EACH(:totals)
@@ -306,7 +307,7 @@
)
BEGIN
- @FILTER(:order, order);
+ @FILTER(:order, order)
UPDATE "order"
diff --git a/admin/sql/pgsql/order_log.sql b/admin/sql/pgsql/order_log.sql
index 3c0d0c1..fb58cae 100644
--- a/admin/sql/pgsql/order_log.sql
+++ b/admin/sql/pgsql/order_log.sql
@@ -46,19 +46,19 @@
PROCEDURE add(
IN order_log ARRAY,
IN order_id INT,
- OUT insert_id
+ OUT fetch_one
)
BEGIN
-- allow only table fields and set defaults for missing values
- :order_log_data = @FILTER(:order_log, order_log);
+ :order_log_data = @FILTER(:order_log, order_log)
INSERT INTO order_log
( @KEYS(:order_log_data), order_id )
- VALUES ( :order_log_data, :order_id );
+ VALUES ( :order_log_data, :order_id ) RETURNING order_log_id;
END
@@ -71,7 +71,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:order_log, order_log);
+ @FILTER(:order_log, order_log)
UPDATE order_log
diff --git a/admin/sql/pgsql/order_status.sql b/admin/sql/pgsql/order_status.sql
index 49a7e83..5aedd4b 100755
--- a/admin/sql/pgsql/order_status.sql
+++ b/admin/sql/pgsql/order_status.sql
@@ -46,19 +46,19 @@
PROCEDURE add(
IN order_status ARRAY,
IN language_id INT,
- OUT insert_id
+ OUT fetch_one
)
BEGIN
-- allow only table fields and set defaults for missing values
- :order_status_data = @FILTER(:order_status, order_status);
+ :order_status_data = @FILTER(:order_status, order_status)
INSERT INTO order_status
( @KEYS(:order_status_data), language_id )
- VALUES ( :order_status_data, :language_id );
+ VALUES ( :order_status_data, :language_id ) RETURNING order_status_id;
END
@@ -71,7 +71,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:order_status, order_status);
+ @FILTER(:order_status, order_status)
UPDATE order_status
diff --git a/admin/sql/pgsql/post.sql b/admin/sql/pgsql/post.sql
index ab05a46..294ccf8 100755
--- a/admin/sql/pgsql/post.sql
+++ b/admin/sql/pgsql/post.sql
@@ -274,22 +274,25 @@
CREATE PROCEDURE add(
IN post ARRAY,
- IN site_id INT,
- OUT insert_id
+ IN site_id ARRAY,
+ OUT fetch_one,
+ OUT fetch_one,
+ OUT fetch_one,
+ OUT fetch_one
)
BEGIN
-- allow only table fields and set defaults for missing values
- :post_data = @FILTER(:post, post);
+ :post_data = @FILTER(:post, post)
INSERT INTO post
( @KEYS(:post_data) )
- VALUES ( :post_data );
+ VALUES ( :post_data ) RETURNING post_id;
- :post.post_content = @FILTER(:post.post_content, post_content, false, true);
+ :post.post_content = @FILTER(:post.post_content, post_content, false, true)
@EACH(:post.post_content)
@@ -307,12 +310,12 @@
VALUES ( :each, @result.post)
ON CONFLICT ("taxonomy_item_id", "post_id") DO UPDATE SET "taxonomy_item_id" = :each;
-
+ @EACH(:site_id)
INSERT INTO post_to_site
( "post_id", "site_id" )
- VALUES ( @result.post, :site_id );
+ VALUES ( @result.post, :each );
END
@@ -321,12 +324,12 @@
CREATE PROCEDURE edit(
IN post ARRAY,
IN post_id INT,
- IN site_id INT,
+ IN site_id ARRAY,
OUT affected_rows
)
BEGIN
- :post.post_content = @FILTER(:post.post_content, post_content, false, true);
+ :post.post_content = @FILTER(:post.post_content, post_content, false, true)
@EACH(:post.post_content)
INSERT INTO post_content
@@ -337,30 +340,35 @@
ON CONFLICT ("post_id", "language_id") DO UPDATE SET @LIST(:each);
- -- @IF isset(:post.taxonomy_item)
-
- DELETE FROM post_to_taxonomy_item WHERE post_id = :post_id;
+ @IF isset(:post.taxonomy_item)
+ THEN
+ DELETE FROM post_to_taxonomy_item WHERE post_id = :post_id
+ END @IF;
@EACH(:post.taxonomy_item)
INSERT INTO post_to_taxonomy_item
- ( "taxonomy_item_id", post_id)
+ ( "taxonomy_item_id", post_id )
VALUES ( :each, :post_id)
ON CONFLICT ("taxonomy_item_id", "post_id") DO UPDATE SET "taxonomy_item_id" = :each;
- -- END @IF
+ @IF isset(:site_id)
+ THEN
+ DELETE FROM post_to_site WHERE post_id = :post_id
+ END @IF;
+ @EACH(:site_id)
INSERT INTO post_to_site
( "post_id", "site_id" )
- VALUES ( :post_id, :site_id )
+ VALUES ( :post_id, :each )
ON CONFLICT ("post_id", "site_id") DO NOTHING;
-- allow only table fields and set defaults for missing values
- @FILTER(:post, post);
+ @FILTER(:post, post)
@IF !empty(:post)
THEN
@@ -369,7 +377,7 @@
SET @LIST(:post)
WHERE post_id = :post_id
- END @IF
+ END @IF;
@@ -385,7 +393,7 @@
)
BEGIN
- :post_content = @FILTER(:post_content, post_content);
+ :post_content = @FILTER(:post_content, post_content)
UPDATE post_content
@@ -400,9 +408,9 @@
CREATE PROCEDURE delete(
IN post_id ARRAY,
IN site_id INT,
- OUT affected_rows
- OUT affected_rows
- OUT affected_rows
+ OUT affected_rows,
+ OUT affected_rows,
+ OUT affected_rows,
OUT affected_rows
)
BEGIN
diff --git a/admin/sql/pgsql/post_content_revision.sql b/admin/sql/pgsql/post_content_revision.sql
index a8f8341..77df20b 100644
--- a/admin/sql/pgsql/post_content_revision.sql
+++ b/admin/sql/pgsql/post_content_revision.sql
@@ -100,7 +100,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :post_content_revision_data = @FILTER(:revision, post_content_revision);
+ :post_content_revision_data = @FILTER(:revision, post_content_revision)
INSERT INTO post_content_revision
@@ -122,7 +122,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:revision, post_content_revision);
+ @FILTER(:revision, post_content_revision)
UPDATE post_content_revision
diff --git a/admin/sql/pgsql/product.sql b/admin/sql/pgsql/product.sql
index 4be65cd..ce0a741 100755
--- a/admin/sql/pgsql/product.sql
+++ b/admin/sql/pgsql/product.sql
@@ -399,13 +399,14 @@
PROCEDURE edit(
IN product ARRAY,
IN product_id INT,
- OUT insert_id
- OUT affected_rows
- OUT affected_rows
+ IN site_id ARRAY,
+ OUT insert_id,
+ OUT affected_rows,
+ OUT affected_rows,
OUT insert_id
)
BEGIN
- :product.product_content = @FILTER(:product.product_content, product_content, false);
+ :product.product_content = @FILTER(:product.product_content, product_content, false)
@EACH(:product.product_content)
INSERT INTO product_content
@@ -417,7 +418,10 @@
ON CONFLICT("product_id", "language_id") DO UPDATE SET @LIST(:each);
- DELETE FROM product_to_taxonomy_item WHERE product_id = :product_id;
+ @IF isset(:product.taxonomy_item)
+ THEN
+ DELETE FROM product_to_taxonomy_item WHERE product_id = :product_id
+ END @IF;
@EACH(:product.taxonomy_item)
INSERT INTO product_to_taxonomy_item
@@ -428,13 +432,22 @@
-- ON CONFLICT("taxonomy_item_id", "product_id") DO UPDATE SET @LIST(:each);
- -- SELECT * FROM product_option WHERE product_id = :product_id;
-
+ @IF isset(:site_id)
+ THEN
+ DELETE FROM product_to_site WHERE product_id = :product_id
+ END @IF;
+
+ @EACH(:site_id)
+ INSERT INTO product_to_site
+
+ ( product_id, site_id )
+
+ VALUES ( :product_id, :each );
-- SELECT * FROM product_option WHERE product_id = :product_id;
-- allow only table fields and set defaults for missing values
- :product_update = @FILTER(:product, product, false);
+ :product_update = @FILTER(:product, product, false)
UPDATE product
@@ -456,7 +469,7 @@
)
BEGIN
- :product_content = @FILTER(:product_content, product_content);
+ :product_content = @FILTER(:product_content, product_content)
UPDATE product_content
@@ -470,21 +483,22 @@
CREATE PROCEDURE add(
IN product ARRAY,
- OUT insert_id,
- OUT insert_id
- OUT insert_id
- OUT insert_id
+ IN site_id ARRAY,
+ OUT fetch_one,
+ OUT fetch_one,
+ OUT fetch_one,
+ OUT fetch_one
)
BEGIN
-- allow only table fields and set defaults for missing values
- :product_data = @FILTER(:product, product);
+ :product_data = @FILTER(:product, product)
INSERT INTO product
( @KEYS(:product_data) )
- VALUES ( :product_data );
+ VALUES ( :product_data ) RETURNING product_id;
:product_content = @FILTER(:product.product_content, product_content, false, true)
@@ -504,13 +518,14 @@
VALUES ( :each, @result.product_data)
ON CONFLICT("taxonomy_item_id", "product_id") DO UPDATE SET @LIST(:each);
- -- :product = @FILTER(:product_data, product);
+ -- :product = @FILTER(:product_data, product)
+ @EACH(:site_id)
INSERT INTO product_to_site
( product_id, site_id )
- VALUES ( @result.product, :site_id );
+ VALUES ( @result.product, :each );
END
@@ -524,7 +539,7 @@
)
BEGIN
- DELETE FROM product_image WHERE product_id = :product_id;
+ DELETE FROM product_image WHERE product_id = :product_id;
@EACH(:product_image)
INSERT INTO product_image
diff --git a/admin/sql/pgsql/product_attribute.sql b/admin/sql/pgsql/product_attribute.sql
index f3f366a..fcf4954 100755
--- a/admin/sql/pgsql/product_attribute.sql
+++ b/admin/sql/pgsql/product_attribute.sql
@@ -46,19 +46,19 @@
PROCEDURE add(
IN product_attribute ARRAY,
- OUT insert_id
+ OUT fetch_one
)
BEGIN
-- allow only table fields and set defaults for missing values
- :product_attribute_data = @FILTER(:product_attribute, product_attribute);
+ :product_attribute_data = @FILTER(:product_attribute, product_attribute)
INSERT INTO product_attribute
( @KEYS(:product_attribute_data) )
- VALUES ( :product_attribute_data );
+ VALUES ( :product_attribute_data ) RETURNING product_attribute_id;
END
@@ -72,7 +72,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:product_attribute, product_attribute);
+ @FILTER(:product_attribute, product_attribute)
UPDATE product_attribute
diff --git a/admin/sql/pgsql/product_content_revision.sql b/admin/sql/pgsql/product_content_revision.sql
index 0ed80d1..1c4e99c 100644
--- a/admin/sql/pgsql/product_content_revision.sql
+++ b/admin/sql/pgsql/product_content_revision.sql
@@ -100,7 +100,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :product_content_revision_data = @FILTER(:revision, product_content_revision);
+ :product_content_revision_data = @FILTER(:revision, product_content_revision)
INSERT INTO product_content_revision
@@ -123,7 +123,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:revision, product_content_revision);
+ @FILTER(:revision, product_content_revision)
UPDATE product_content_revision
diff --git a/admin/sql/pgsql/product_option.sql b/admin/sql/pgsql/product_option.sql
index e00ef51..f59c2aa 100755
--- a/admin/sql/pgsql/product_option.sql
+++ b/admin/sql/pgsql/product_option.sql
@@ -60,19 +60,19 @@
PROCEDURE add(
IN product_option ARRAY,
- OUT insert_id
+ OUT fetch_one
)
BEGIN
-- allow only table fields and set defaults for missing values
- :product_option_data = @FILTER(:product_option, product_option);
+ :product_option_data = @FILTER(:product_option, product_option)
INSERT INTO product_option
( @KEYS(:product_option_data) )
- VALUES ( :product_option_data );
+ VALUES ( :product_option_data ) RETURNING product_option_id;
END
@@ -86,7 +86,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:product_option, product_option);
+ @FILTER(:product_option, product_option)
UPDATE product_option
diff --git a/admin/sql/pgsql/product_option_value.sql b/admin/sql/pgsql/product_option_value.sql
index 6d3647f..ad07329 100644
--- a/admin/sql/pgsql/product_option_value.sql
+++ b/admin/sql/pgsql/product_option_value.sql
@@ -77,19 +77,19 @@
PROCEDURE add(
IN product_option_value ARRAY,
- OUT insert_id
+ OUT fetch_one
)
BEGIN
-- allow only table fields and set defaults for missing values
- :product_option_value_data = @FILTER(:product_option_value, product_option_value);
+ :product_option_value_data = @FILTER(:product_option_value, product_option_value)
INSERT INTO product_option_value
( @KEYS(:product_option_value_data) )
- VALUES ( :product_option_value_data );
+ VALUES ( :product_option_value_data ) RETURNING product_option_value_id;
END
@@ -105,7 +105,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :product_option_value_data = @FILTER(:product_option_value, product_option_value);
+ :product_option_value_data = @FILTER(:product_option_value, product_option_value)
UPDATE product_option_value
diff --git a/admin/sql/pgsql/product_question.sql b/admin/sql/pgsql/product_question.sql
index 5fde8eb..eb7876a 100755
--- a/admin/sql/pgsql/product_question.sql
+++ b/admin/sql/pgsql/product_question.sql
@@ -18,9 +18,9 @@
)
BEGIN
- SELECT user.*,product_question.*,user.user_id as user_id
+ SELECT "user".*, product_question.*, "user".user_id as user_id
FROM product_question AS product_question
- LEFT JOIN user on user.user_id = product_question.user_id
+ LEFT JOIN "user" on "user".user_id = product_question.user_id
WHERE 1 = 1
@@ -69,7 +69,7 @@
-- question
SELECT *
FROM product_question as _ -- (underscore) _ means that data will be kept in main array
- INNER JOIN user on user.user_id = _.user_id
+ INNER JOIN "user" on "user".user_id = _.user_id
WHERE product_question_id = :product_question_id LIMIT 1;
END
@@ -78,18 +78,18 @@
CREATE PROCEDURE add(
IN product_question ARRAY,
- OUT insert_id
+ OUT fetch_one
)
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:product_question, product_question);
+ @FILTER(:product_question, product_question)
INSERT INTO product_question
( @KEYS(:product_question) )
- VALUES ( :product_question )
+ VALUES ( :product_question ) RETURNING product_question_id;
END
@@ -102,7 +102,7 @@
)
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:product_question, product_question);
+ @FILTER(:product_question, product_question)
UPDATE product_question
diff --git a/admin/sql/pgsql/product_review.sql b/admin/sql/pgsql/product_review.sql
index e482bac..c4f9743 100755
--- a/admin/sql/pgsql/product_review.sql
+++ b/admin/sql/pgsql/product_review.sql
@@ -20,13 +20,13 @@
)
BEGIN
- SELECT user.*,product_review.*,user.user_id as user_id,
+ SELECT "user".*, product_review.*, "user".user_id as user_id,
(SELECT json_agg(json_build_object('id',prm.product_review_media_id,'image',prm.image))
FROM product_review_media as prm
WHERE prm.product_review_id = product_review.product_review_id) as images
FROM product_review
- LEFT JOIN user ON user.user_id = product_review.user_id
+ LEFT JOIN "user" ON "user".user_id = product_review.user_id
WHERE 1 = 1
@@ -75,7 +75,7 @@
-- review
SELECT *
FROM product_review as _ -- (underscore) _ means that data will be kept in main array
- INNER JOIN user on user.user_id = _.user_id
+ INNER JOIN "user" on "user".user_id = _.user_id
WHERE product_review_id = :product_review_id LIMIT 1;
END
@@ -162,18 +162,18 @@
CREATE PROCEDURE add(
IN product_review ARRAY,
- OUT insert_id
+ OUT fetch_one
)
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:product_review, product_review);
+ @FILTER(:product_review, product_review)
INSERT INTO product_review
( @KEYS(:product_review) )
- VALUES ( :product_review )
+ VALUES ( :product_review ) RETURNING product_review_id
END
@@ -186,7 +186,7 @@
)
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:product_review, product_review);
+ @FILTER(:product_review, product_review)
UPDATE product_review
diff --git a/admin/sql/pgsql/product_review_media.sql b/admin/sql/pgsql/product_review_media.sql
index e8f1b34..9e7a908 100644
--- a/admin/sql/pgsql/product_review_media.sql
+++ b/admin/sql/pgsql/product_review_media.sql
@@ -75,18 +75,18 @@
CREATE PROCEDURE add(
IN product_review_media ARRAY,
- OUT insert_id
+ OUT fetch_one
)
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:product_review_media, product_review_media);
+ @FILTER(:product_review_media, product_review_media)
INSERT INTO product_review_media
( @KEYS(:product_review_media) )
- VALUES ( :product_review_media )
+ VALUES ( :product_review_media ) RETURNING product_review_id;
END
@@ -99,7 +99,7 @@
)
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:product_review_media, product_review_media);
+ @FILTER(:product_review_media, product_review_media)
UPDATE product_review_media
diff --git a/admin/sql/pgsql/product_subscription.sql b/admin/sql/pgsql/product_subscription.sql
index ca4c8e3..64573a7 100644
--- a/admin/sql/pgsql/product_subscription.sql
+++ b/admin/sql/pgsql/product_subscription.sql
@@ -74,19 +74,19 @@
PROCEDURE add(
IN product_subscription ARRAY,
- OUT insert_id
+ OUT fetch_one
)
BEGIN
-- allow only table fields and set defaults for missing values
- :product_subscription_data = @FILTER(:product_subscription, product_subscription);
+ :product_subscription_data = @FILTER(:product_subscription, product_subscription)
INSERT INTO product_subscription
( @KEYS(:product_subscription_data) )
- VALUES ( :product_subscription_data );
+ VALUES ( :product_subscription_data ) RETURNING product_subscription_id;
END
@@ -100,7 +100,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:product_subscription, product_subscription);
+ @FILTER(:product_subscription, product_subscription)
UPDATE product_subscription
diff --git a/admin/sql/pgsql/region.sql b/admin/sql/pgsql/region.sql
index eef10cd..23ee253 100755
--- a/admin/sql/pgsql/region.sql
+++ b/admin/sql/pgsql/region.sql
@@ -69,19 +69,19 @@
PROCEDURE add(
IN region ARRAY,
IN language_id INT,
- OUT insert_id
+ OUT fetch_one
)
BEGIN
-- allow only table fields and set defaults for missing values
- :region_data = @FILTER(:region, region);
+ :region_data = @FILTER(:region, region)
INSERT INTO region
( @KEYS(:region_data) )
- VALUES ( :region_data );
+ VALUES ( :region_data ) RETURNING region_id;
END
@@ -95,7 +95,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:region, region);
+ @FILTER(:region, region)
UPDATE region
diff --git a/admin/sql/pgsql/region_group.sql b/admin/sql/pgsql/region_group.sql
index 816fe61..4103988 100755
--- a/admin/sql/pgsql/region_group.sql
+++ b/admin/sql/pgsql/region_group.sql
@@ -81,7 +81,7 @@
DELETE FROM region_to_region_group WHERE region_group_id = :region_group_id;
-- allow only table fields and set defaults for missing values
- :region_to_region_group_data = @FILTER(:region_to_region_group, region_to_region_group);
+ :region_to_region_group_data = @FILTER(:region_to_region_group, region_to_region_group)
@EACH(:region_to_region_group_data)
@@ -111,19 +111,19 @@
PROCEDURE add(
IN region_group ARRAY,
- OUT insert_id
+ OUT fetch_one
)
BEGIN
-- allow only table fields and set defaults for missing values
- :region_group_data = @FILTER(:region_group, region_group);
+ :region_group_data = @FILTER(:region_group, region_group)
INSERT INTO region_group
( @KEYS(:region_group_data) )
- VALUES ( :region_group_data );
+ VALUES ( :region_group_data ) RETURNING region_id;
END
@@ -137,7 +137,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:region_group, region_group);
+ @FILTER(:region_group, region_group)
UPDATE region_group
diff --git a/admin/sql/pgsql/return.sql b/admin/sql/pgsql/return.sql
index 9fb0959..866fe15 100755
--- a/admin/sql/pgsql/return.sql
+++ b/admin/sql/pgsql/return.sql
@@ -49,19 +49,19 @@
PROCEDURE add(
IN return ARRAY,
- OUT insert_id
+ OUT fetch_one
)
BEGIN
-- allow only table fields and set defaults for missing values
- :return_data = @FILTER(:return, return);
+ :return_data = @FILTER(:return, return)
INSERT INTO return
( @KEYS(:return_data) )
- VALUES ( :return_data );
+ VALUES ( :return_data ) RETURNING return_id;
END
@@ -74,7 +74,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:return, return);
+ @FILTER(:return, return)
UPDATE return
diff --git a/admin/sql/pgsql/return_reason.sql b/admin/sql/pgsql/return_reason.sql
index 18978b9..9583a96 100755
--- a/admin/sql/pgsql/return_reason.sql
+++ b/admin/sql/pgsql/return_reason.sql
@@ -46,19 +46,19 @@
PROCEDURE add(
IN return_reason ARRAY,
IN language_id INT,
- OUT insert_id
+ OUT fetch_one
)
BEGIN
-- allow only table fields and set defaults for missing values
- :return_reason_data = @FILTER(:return_reason, return_reason);
+ :return_reason_data = @FILTER(:return_reason, return_reason)
INSERT INTO return_reason
( @KEYS(:return_reason_data), language_id )
- VALUES ( :return_reason_data, :language_id );
+ VALUES ( :return_reason_data, :language_id ) RETURNING return_reason_id;
END
@@ -71,7 +71,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:return_reason, return_reason);
+ @FILTER(:return_reason, return_reason)
UPDATE return_reason
diff --git a/admin/sql/pgsql/return_resolution.sql b/admin/sql/pgsql/return_resolution.sql
index 944d206..639ced6 100755
--- a/admin/sql/pgsql/return_resolution.sql
+++ b/admin/sql/pgsql/return_resolution.sql
@@ -46,20 +46,20 @@
PROCEDURE add(
IN return_resolution ARRAY,
IN language_id INT,
- OUT insert_id
+ OUT fetch_one
)
BEGIN
-- allow only table fields and set defaults for missing values
- :return_resolution_data = @FILTER(:return_resolution, return_resolution);
+ :return_resolution_data = @FILTER(:return_resolution, return_resolution)
INSERT INTO return_resolution
( @KEYS(:return_resolution_data), language_id )
- VALUES ( :return_resolution_data, :language_id );
-
+ VALUES ( :return_resolution_data, :language_id ) RETURNING return_resolution_id;
+
END
-- edit return_resolution
@@ -71,7 +71,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:return_resolution, return_resolution);
+ @FILTER(:return_resolution, return_resolution)
UPDATE return_resolution
diff --git a/admin/sql/pgsql/return_status.sql b/admin/sql/pgsql/return_status.sql
index 39d74d4..cc1f32a 100755
--- a/admin/sql/pgsql/return_status.sql
+++ b/admin/sql/pgsql/return_status.sql
@@ -46,19 +46,19 @@
PROCEDURE add(
IN return_status ARRAY,
IN language_id INT,
- OUT insert_id
+ OUT fetch_one
)
BEGIN
-- allow only table fields and set defaults for missing values
- :return_status_data = @FILTER(:return_status, return_status);
+ :return_status_data = @FILTER(:return_status, return_status)
INSERT INTO return_status
( @KEYS(:return_status_data), language_id )
- VALUES ( :return_status_data, :language_id );
+ VALUES ( :return_status_data, :language_id ) RETURNING return_status_id;
END
@@ -72,7 +72,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:return_status, return_status);
+ @FILTER(:return_status, return_status)
UPDATE return_status
diff --git a/admin/sql/pgsql/role.sql b/admin/sql/pgsql/role.sql
index fa5da55..72d2537 100755
--- a/admin/sql/pgsql/role.sql
+++ b/admin/sql/pgsql/role.sql
@@ -51,18 +51,18 @@
CREATE PROCEDURE add(
IN role ARRAY,
- OUT insert_id
+ OUT fetch_one
)
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:role, role);
+ @FILTER(:role, role)
INSERT INTO role
( @KEYS(:role) )
- VALUES ( :role )
+ VALUES ( :role ) RETURNING role_id;
END
@@ -75,7 +75,7 @@
)
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:role, role);
+ @FILTER(:role, role)
UPDATE role
diff --git a/admin/sql/pgsql/setting.sql b/admin/sql/pgsql/setting.sql
index 9fd5957..510968e 100755
--- a/admin/sql/pgsql/setting.sql
+++ b/admin/sql/pgsql/setting.sql
@@ -2,10 +2,10 @@
-- get one setting
- CREATE PROCEDURE getSetting(
+ CREATE PROCEDURE get(
+ IN site_id INT,
IN namespace CHAR,
IN key CHAR,
- IN site_id INT,
OUT fetch_one,
)
@@ -28,110 +28,105 @@
END
- CREATE PROCEDURE setSetting(
+ CREATE PROCEDURE set(
+ IN site_id INT,
IN namespace CHAR,
IN key CHAR,
IN value CHAR,
- IN site_id INT,
OUT insert_id
)
BEGIN
- INSERT INTO setting
- (namespace, "key", value, site_id)
+ INSERT INTO setting
+ (site_id, namespace, "key", value)
- VALUES ( :namespace, :key, :value, :site_id )
+ VALUES ( :site_id, :namespace, :key, :value )
- ON CONFLICT(`site_id`, `namespace`, `key`) DO UPDATE SET `value` = :value;
+ ON CONFLICT("site_id", "namespace", "key") DO UPDATE SET "value" = :value;
END
- CREATE PROCEDURE delete(
- IN namespace CHAR,
- IN key CHAR,
- )
- BEGIN
-
- DELETE FROM
- setting
- WHERE "key" = :key;
-
- END
- CREATE PROCEDURE getSettings(
+ CREATE PROCEDURE getMulti(
+ IN site_id INT,
IN namespace CHAR,
IN key ARRAY,
- IN site_id INT,
- OUT fetch_all,
+ OUT fetch_all
)
BEGIN
SELECT namespace, "key", value
- FROM setting AS _
+ FROM setting AS _
WHERE 1 = 1
- @IF !empty(:namespace)
+
+ @IF !empty(:site_id)
THEN
- AND _.namespace = :namespace
+ AND _.site_id = :site_id
END @IF
- @IF !empty(:key)
+ @IF !empty(:namespace)
THEN
- AND _."key"IN (:key)
+ AND _.namespace = :namespace
END @IF
- @IF !empty(:site_id)
+ @IF !empty(:key)
THEN
- AND _.site_id = :site_id
+ AND _."key" IN (:key)
END @IF
;
END
- CREATE PROCEDURE setSettings(
+ CREATE PROCEDURE setMulti(
+ IN site_id INT,
IN namespace CHAR,
IN settings ARRAY,
- IN site_id INT,
+
+ OUT insert_id
)
BEGIN
- INSERT INTO setting
- (namespace, "key", value, site_id)
-
- -- @EACH(:settings)
- VALUES (namespace, :each, :site_id)
- -- END @EACH
+ -- :settings = @FILTER(:settings, setting, false, true)
+
+ @EACH(:settings)
+ INSERT INTO setting
- -- @VALUES(:settings) --@VALUES expands the array to the following expression
- -- ( :settings.each."key", :settings.each.value, :site_id )
-
- ON DUPLICATE KEY
- UPDATE value = VALUES(value);
+ ( site_id, namespace, "key", value )
+
+ VALUES ( :site_id, :namespace, :each_key, :each )
+
+ ON CONFLICT("site_id", "namespace", "key") DO UPDATE SET "value" = :each;
END
- CREATE PROCEDURE deleteSettings(
- IN namespace CHAR,
- IN keys ARRAY,
+ CREATE PROCEDURE delete(
IN site_id,
+ IN namespace CHAR,
+ IN key ARRAY
)
BEGIN
- DELETE FROM
- setting
- WHERE "key" IN (:keys)
+ DELETE FROM
+ setting
+ WHERE 1 = 1
@IF !empty(:namespace)
THEN
- AND _.namespace = :namespace
+ AND namespace = :namespace
+ END @IF
+
+ @IF !empty(:key)
+ THEN
+ AND "key" IN (:key)
END @IF
@IF !empty(:site_id)
THEN
- AND _.site_id = :site_id
+ AND site_id = :site_id
END @IF
;
- END
+ END
diff --git a/admin/sql/pgsql/setting_content.sql b/admin/sql/pgsql/setting_content.sql
index 11183a6..ff35ee7 100755
--- a/admin/sql/pgsql/setting_content.sql
+++ b/admin/sql/pgsql/setting_content.sql
@@ -1,36 +1,50 @@
--- Setting contents
+-- Setting content
-- get one setting content
CREATE PROCEDURE get(
- IN key ARRAY,
IN site_id INT,
+ IN namespace CHAR,
+ IN key CHAR,
IN language_id INT,
+
+ OUT fetch_one
)
BEGIN
- SELECT "key", value
- FROM setting_content AS _
- WHERE _.keyIN (:key)
+ SELECT `key`, value
+ FROM setting_content AS _
+ WHERE 1 = 1
- @IF !empty(:language_id)
+ @IF !empty(:site_id)
THEN
AND _.site_id = :site_id
+ END @IF
+
+ @IF !empty(:namespace)
+ THEN
+ AND _.namespace = :namespace
+ END @IF
+
+ @IF !empty(:key)
+ THEN
+ AND _.`key` = :key
END @IF
@IF !empty(:language_id)
THEN
AND _.language_id = :language_id
END @IF
+ ;
END
-
- CREATE PROCEDURE _set(
+ CREATE PROCEDURE set(
+ IN site_id INT,
+ IN namespace CHAR,
IN key CHAR,
IN value CHAR,
- IN site_id INT,
IN language_id INT,
OUT insert_id
@@ -38,47 +52,102 @@
BEGIN
INSERT INTO setting_content
- ("key", value, site_id, language_id)
+ (`namespace`,`key`, value, site_id, language_id)
VALUES ( :key, :value, :site_id , :language_id )
- ON CONFLICT(`site_id`, `language_id`, `key`) DO UPDATE SET `value` = :value;
+ ON CONFLICT("site_id", "language_id", "namespace", "key") DO UPDATE SET "value" = :value;
END
-
-
- CREATE PROCEDURE set(
- IN setting_content ARRAY,
+ CREATE PROCEDURE getMulti(
IN site_id INT,
+ IN namespace CHAR,
+ IN key ARRAY,
IN language_id INT,
+
+ OUT fetch_all
)
BEGIN
- INSERT INTO setting_content
- ("key", value, site_id, language_id)
-
- -- @EACH(:setting_contents)
- VALUES ( :each, :site_id, :language_id)
- -- END @EACH
+ SELECT site_id, namespace, "key", value, language_id
+ FROM setting_content AS _
+ WHERE 1 = 1
- -- @VALUES(:setting_contents) --@VALUES expands the array to the following expression
- -- ( :setting_contents.each.key, :setting_contents.each.value, :site_id )
-
- ON DUPLICATE KEY
- UPDATE value = VALUES(value);
+ @IF !empty(:site_id)
+ THEN
+ AND _.site_id = :site_id
+ END @IF
- END
+ @IF !empty(:namespace)
+ THEN
+ AND _.namespace = :namespace
+ END @IF
+
+ @IF !empty(:key)
+ THEN
+ AND _."key" IN (:key)
+ END @IF
+
+ @IF !empty(:language_id)
+ THEN
+ AND _.language_id = :language_id
+ END @IF
+ ;
+
+ END
+
+ CREATE PROCEDURE setMulti(
+ IN site_id INT,
+ IN meta ARRAY,
+
+ OUT insert_id
+ )
+ BEGIN
+
+ :meta = @FILTER(:meta, setting_content, false, true)
+
+ @EACH(:meta)
+ INSERT INTO setting_content
+
+ ( @KEYS(:each), site_id)
+
+ VALUES ( :each, :site_id )
+ ON CONFLICT("site_id", "language_id", "namespace", "key") DO UPDATE SET "value" = :each.value;
+
+ END
+
CREATE PROCEDURE delete(
- IN keys ARRAY,
IN site_id,
- IN language_id INT,
+ IN namespace CHAR,
+ IN key ARRAY,
+ IN language_id INT
)
BEGIN
DELETE FROM
setting_content
- WHERE "key" IN (:keys) AND site_id = :site_id AND language_id = :language_id;
+ WHERE 1 = 1
+ @IF !empty(:namespace)
+ THEN
+ AND namespace = :namespace
+ END @IF
+
+ @IF !empty(:key)
+ THEN
+ AND "key" IN (:key)
+ END @IF
+
+ @IF !empty(:language_id)
+ THEN
+ AND language_id = :language_id
+ END @IF
+
+ @IF !empty(:site_id)
+ THEN
+ AND site_id = :site_id
+ END @IF
+ ;
END
diff --git a/admin/sql/pgsql/site.sql b/admin/sql/pgsql/site.sql
index f9bdf1c..458391d 100755
--- a/admin/sql/pgsql/site.sql
+++ b/admin/sql/pgsql/site.sql
@@ -17,7 +17,7 @@
SELECT *, site_id as array_key
FROM site as sites
- WHERE 1
+ WHERE 1 = 1
-- site_id
@IF isset(:site_id) && !empty(:site_id)
@@ -124,19 +124,19 @@
PROCEDURE add(
IN site ARRAY,
- OUT insert_id
+ OUT fetch_one
)
BEGIN
-- allow only table fields and set defaults for missing values
- :site_data = @FILTER(:site, site);
+ :site_data = @FILTER(:site, site)
INSERT INTO site
( @KEYS(:site_data) )
- VALUES ( :site_data );
+ VALUES ( :site_data ) RETURNING site_id;
END
@@ -149,7 +149,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :site_data = @FILTER(:site, site);
+ :site_data = @FILTER(:site, site)
UPDATE site
diff --git a/admin/sql/pgsql/stat.sql b/admin/sql/pgsql/stat.sql
index 2010058..6c0a07e 100755
--- a/admin/sql/pgsql/stat.sql
+++ b/admin/sql/pgsql/stat.sql
@@ -20,7 +20,7 @@
-- orders
- SELECT COUNT(*) AS orders, DATE(created_at) as date, orders.created_at FROM "order" AS orders
+ SELECT COUNT(*) AS orders, DATE(created_at) as date FROM "order" AS orders
LEFT JOIN order_status AS os ON (orders.order_status_id = os.order_status_id AND os.language_id = :language_id)
@@ -45,12 +45,12 @@
END @IF
- GROUP BY date,orders.created_at ORDER BY date;
+ GROUP BY date ORDER BY date;
-- users
- SELECT COUNT(*) AS users, DATE(created_at) as date, users.created_at FROM "user" AS users
+ SELECT COUNT(*) AS users, DATE(created_at) as date FROM "user" AS users
WHERE 1 = 1
@@ -66,7 +66,7 @@
END @IF
- GROUP BY date, users.created_at ORDER BY date;
+ GROUP BY date ORDER BY date;
END
@@ -88,7 +88,7 @@
-- orders
SELECT COUNT(*) AS count, os.name, orders.order_status_id, orders.order_status_id as array_key
- FROM `order` AS orders
+ FROM "order" AS orders
LEFT JOIN order_status AS os ON (orders.order_status_id = os.order_status_id AND os.language_id = :language_id)
WHERE 1 = 1
@@ -132,7 +132,7 @@
-- users
- SELECT COUNT(*) AS count, YEAR(users.created_at) AS year, MONTH(users.created_at) AS month FROM `user` AS users
+ SELECT COUNT(*) AS count, date_part('year',users.created_at) AS year, date_part('month',users.created_at) AS month FROM "user" AS users
WHERE 1 = 1
@@ -148,7 +148,7 @@
END @IF
- GROUP BY MONTH(users.created_at), YEAR(users.created_at);
+ GROUP BY month, year;
END
diff --git a/admin/sql/pgsql/stock_status.sql b/admin/sql/pgsql/stock_status.sql
index 0d49741..c8949ea 100755
--- a/admin/sql/pgsql/stock_status.sql
+++ b/admin/sql/pgsql/stock_status.sql
@@ -46,19 +46,19 @@
PROCEDURE add(
IN stock_status ARRAY,
IN language_id INT,
- OUT insert_id
+ OUT fetch_one
)
BEGIN
-- allow only table fields and set defaults for missing values
- :stock_status_data = @FILTER(:stock_status, stock_status);
+ :stock_status_data = @FILTER(:stock_status, stock_status)
INSERT INTO stock_status
( @KEYS(:stock_status_data), language_id )
- VALUES ( :stock_status_data, :language_id );
+ VALUES ( :stock_status_data, :language_id ) RETURNING role_id;
END
@@ -71,7 +71,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:stock_status, stock_status);
+ @FILTER(:stock_status, stock_status)
UPDATE stock_status
diff --git a/admin/sql/pgsql/subscription.sql b/admin/sql/pgsql/subscription.sql
index 7f25319..f225d30 100755
--- a/admin/sql/pgsql/subscription.sql
+++ b/admin/sql/pgsql/subscription.sql
@@ -44,19 +44,19 @@
PROCEDURE add(
IN subscription ARRAY,
- OUT insert_id
+ OUT fetch_one
)
BEGIN
-- allow only table fields and set defaults for missing values
- :subscription_data = @FILTER(:subscription, subscription);
+ :subscription_data = @FILTER(:subscription, subscription)
INSERT INTO subscription
( @KEYS(:subscription_data) )
- VALUES ( :subscription_data );
+ VALUES ( :subscription_data ) RETURNING subscription_id;
END
@@ -70,7 +70,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:subscription, subscription);
+ @FILTER(:subscription, subscription)
UPDATE subscription
diff --git a/admin/sql/pgsql/subscription_plan.sql b/admin/sql/pgsql/subscription_plan.sql
index ab6ba84..d21a2c1 100755
--- a/admin/sql/pgsql/subscription_plan.sql
+++ b/admin/sql/pgsql/subscription_plan.sql
@@ -51,19 +51,18 @@
PROCEDURE add(
IN subscription_plan ARRAY,
- OUT insert_id
+ OUT fetch_one
)
BEGIN
-- allow only table fields and set defaults for missing values
- :subscription_plan_data = @FILTER(:subscription_plan, subscription_plan);
-
+ :subscription_plan_data = @FILTER(:subscription_plan, subscription_plan)
INSERT INTO subscription_plan
( @KEYS(:subscription_plan_data) )
- VALUES ( :subscription_plan_data );
+ VALUES ( :subscription_plan_data ) RETURNING subscription_id;
END
@@ -77,7 +76,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:subscription_plan, subscription_plan);
+ @FILTER(:subscription_plan, subscription_plan)
UPDATE subscription_plan
diff --git a/admin/sql/pgsql/subscription_status.sql b/admin/sql/pgsql/subscription_status.sql
index cc5dd82..d061427 100755
--- a/admin/sql/pgsql/subscription_status.sql
+++ b/admin/sql/pgsql/subscription_status.sql
@@ -46,19 +46,19 @@
PROCEDURE add(
IN subscription_status ARRAY,
IN language_id INT,
- OUT insert_id
+ OUT fetch_one
)
BEGIN
-- allow only table fields and set defaults for missing values
- :subscription_status_data = @FILTER(:subscription_status, subscription_status);
+ :subscription_status_data = @FILTER(:subscription_status, subscription_status)
INSERT INTO subscription_status
( @KEYS(:subscription_status_data), language_id )
- VALUES ( :subscription_status_data, :language_id );
+ VALUES ( :subscription_status_data, :language_id ) RETURNING subscription_status_id;
END
@@ -71,7 +71,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:subscription_status, subscription_status);
+ @FILTER(:subscription_status, subscription_status)
UPDATE subscription_status
diff --git a/admin/sql/pgsql/tax_rate.sql b/admin/sql/pgsql/tax_rate.sql
index 2dc96e1..6c8f88f 100755
--- a/admin/sql/pgsql/tax_rate.sql
+++ b/admin/sql/pgsql/tax_rate.sql
@@ -46,19 +46,19 @@
PROCEDURE add(
IN tax_rate ARRAY,
- OUT insert_id
+ OUT fetch_one
)
BEGIN
-- allow only table fields and set defaults for missing values
- :tax_rate_data = @FILTER(:tax_rate, tax_rate);
+ :tax_rate_data = @FILTER(:tax_rate, tax_rate)
INSERT INTO tax_rate
( @KEYS(:tax_rate_data) )
- VALUES ( :tax_rate_data);
+ VALUES ( :tax_rate_data) RETURNING tax_rate_id;
END
@@ -71,7 +71,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:tax_rate, tax_rate);
+ @FILTER(:tax_rate, tax_rate)
UPDATE tax_rate
diff --git a/admin/sql/pgsql/tax_rule.sql b/admin/sql/pgsql/tax_rule.sql
index 512501e..146e390 100755
--- a/admin/sql/pgsql/tax_rule.sql
+++ b/admin/sql/pgsql/tax_rule.sql
@@ -52,7 +52,7 @@
PROCEDURE add(
IN tax_rule ARRAY,
IN tax_type_id INT,
- OUT insert_id
+ OUT fetch_one
)
BEGIN
-- BEGIN transaction;
@@ -60,7 +60,7 @@
DELETE FROM tax_rule WHERE tax_type_id = :tax_type_id;
-- allow only table fields and set defaults for missing values
- :tax_rule_data = @FILTER(:tax_rule, tax_rule);
+ :tax_rule_data = @FILTER(:tax_rule, tax_rule)
@EACH(:tax_rule_data)
@@ -68,7 +68,7 @@
( @KEYS(:each), tax_type_id )
- VALUES ( :each, :tax_type_id );
+ VALUES ( :each, :tax_type_id ) RETURNING tax_rule_id;
-- END transaction;
@@ -84,7 +84,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:tax_rule, tax_rule);
+ @FILTER(:tax_rule, tax_rule)
UPDATE tax_rule
diff --git a/admin/sql/pgsql/tax_type.sql b/admin/sql/pgsql/tax_type.sql
index 1180b70..879b976 100755
--- a/admin/sql/pgsql/tax_type.sql
+++ b/admin/sql/pgsql/tax_type.sql
@@ -76,19 +76,19 @@
PROCEDURE add(
IN tax_type ARRAY,
- OUT insert_id
+ OUT fetch_one
)
BEGIN
-- allow only table fields and set defaults for missing values
- :tax_type_data = @FILTER(:tax_type, tax_type);
+ :tax_type_data = @FILTER(:tax_type, tax_type)
INSERT INTO tax_type
( @KEYS(:tax_type_data) )
- VALUES ( :tax_type_data );
+ VALUES ( :tax_type_data ) RETURNING tax_type_id;
END
@@ -101,7 +101,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:tax_type, tax_type);
+ @FILTER(:tax_type, tax_type)
UPDATE tax_type
diff --git a/admin/sql/pgsql/taxonomy.sql b/admin/sql/pgsql/taxonomy.sql
index 54980e4..b57b372 100755
--- a/admin/sql/pgsql/taxonomy.sql
+++ b/admin/sql/pgsql/taxonomy.sql
@@ -68,19 +68,19 @@
PROCEDURE add(
IN taxonomy ARRAY,
- OUT insert_id
+ OUT fetch_one
)
BEGIN
-- allow only table fields and set defaults for missing values
- :taxonomy_data = @FILTER(:taxonomy, taxonomy);
+ :taxonomy_data = @FILTER(:taxonomy, taxonomy)
INSERT INTO taxonomy
( @KEYS(:taxonomy_data) )
- VALUES ( :taxonomy_data);
+ VALUES ( :taxonomy_data) RETURNING taxonomy_id;
END
@@ -93,7 +93,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:taxonomy, taxonomy);
+ @FILTER(:taxonomy, taxonomy)
UPDATE taxonomy
diff --git a/admin/sql/pgsql/taxonomy_item.sql b/admin/sql/pgsql/taxonomy_item.sql
index c95e53f..f55a456 100755
--- a/admin/sql/pgsql/taxonomy_item.sql
+++ b/admin/sql/pgsql/taxonomy_item.sql
@@ -39,19 +39,19 @@
PROCEDURE add(
IN taxonomy_item ARRAY,
- OUT insert_id
+ OUT fetch_one
)
BEGIN
-- allow only table fields and set defaults for missing values
- :taxonomy_item_data = @FILTER(:taxonomy_item, taxonomy_item);
+ :taxonomy_item_data = @FILTER(:taxonomy_item, taxonomy_item)
INSERT INTO taxonomy_item
( @KEYS(:taxonomy_item_data) )
- VALUES ( :taxonomy_item_data );
+ VALUES ( :taxonomy_item_data ) RETURNING taxonomy_item_id;
END
@@ -64,7 +64,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:taxonomy_item, taxonomy_item);
+ @FILTER(:taxonomy_item, taxonomy_item)
UPDATE taxonomy_item
diff --git a/admin/sql/pgsql/user.sql b/admin/sql/pgsql/user.sql
index 9be9ae6..69ebf64 100755
--- a/admin/sql/pgsql/user.sql
+++ b/admin/sql/pgsql/user.sql
@@ -22,25 +22,25 @@
@IF isset(:status) AND !empty(:status)
THEN
- AND user.status = :status
+ AND "user".status = :status
END @IF
@IF isset(:email) AND !empty(:email)
THEN
- AND user.email = :email
+ AND "user".email = :email
END @IF
@IF isset(:phone_number) AND !empty(:phone_number)
THEN
- AND user.phone_number = :phone_number
+ AND "user".phone_number = :phone_number
END @IF
-- search
@IF isset(:search) AND !empty(:search)
THEN
- AND user.username LIKE '%' || :search || '%' OR
- user.first_name LIKE '%' || :search || '%' OR
- user.last_name LIKE '%' || :search || '%'
+ AND "user".username LIKE '%' || :search || '%' OR
+ "user".first_name LIKE '%' || :search || '%' OR
+ "user".last_name LIKE '%' || :search || '%'
END @IF
@@ -53,7 +53,7 @@
-- SELECT FOUND_ROWS() as count;
SELECT count(*) FROM (
- @SQL_COUNT(user.user_id, user) -- this takes previous query removes limit and replaces select columns with parameter user_id
+ @SQL_COUNT("user".user_id, user) -- this takes previous query removes limit and replaces select columns with parameter user_id
) as count;
@@ -70,7 +70,7 @@
)
BEGIN
- SELECT * FROM user AS _ WHERE 1 = 1
+ SELECT * FROM "user" AS _ WHERE 1 = 1
@IF isset(:username)
THEN
@@ -106,18 +106,18 @@
CREATE PROCEDURE add(
IN user ARRAY,
- OUT insert_id
+ OUT fetch_one
)
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:user, user);
+ @FILTER(:user, user)
- INSERT INTO user
+ INSERT INTO "user"
( @KEYS(:user) )
- VALUES ( :user );
+ VALUES ( :user ) RETURNING user_id;
END
@@ -132,9 +132,9 @@
)
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:user, user);
+ @FILTER(:user, user)
- UPDATE user
+ UPDATE "user"
SET @LIST(:user)
@@ -164,7 +164,7 @@
)
BEGIN
- DELETE FROM user WHERE user_id IN (:user_id);
+ DELETE FROM "user" WHERE user_id IN (:user_id);
END
@@ -179,7 +179,7 @@
BEGIN
- UPDATE user
+ UPDATE "user"
SET
diff --git a/admin/sql/pgsql/user_address.sql b/admin/sql/pgsql/user_address.sql
index 6682210..1a83494 100755
--- a/admin/sql/pgsql/user_address.sql
+++ b/admin/sql/pgsql/user_address.sql
@@ -59,7 +59,7 @@
LIMIT 1;
- -- SELECT `key` as array_key,value as array_value FROM user_address_meta as _
+ -- SELECT "key" as array_key,value as array_value FROM user_address_meta as _
-- WHERE _.user_address_id = @result.user_address_id
@@ -69,18 +69,18 @@
CREATE PROCEDURE add(
IN user_address ARRAY,
- OUT insert_id
+ OUT fetch_one
)
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:user_address, user_address);
+ @FILTER(:user_address, user_address)
INSERT INTO user_address
( @KEYS(:user_address) )
- VALUES ( :user_address )
+ VALUES ( :user_address ) RETURNING user_address_id;
END
@@ -94,7 +94,7 @@
)
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:user_address, user_address);
+ @FILTER(:user_address, user_address)
UPDATE user_address
diff --git a/admin/sql/pgsql/user_group.sql b/admin/sql/pgsql/user_group.sql
index fc86caa..30e60dd 100755
--- a/admin/sql/pgsql/user_group.sql
+++ b/admin/sql/pgsql/user_group.sql
@@ -57,21 +57,21 @@
PROCEDURE add(
IN user_group ARRAY,
IN language_id INT,
- OUT insert_id
+ OUT fetch_one
OUT insert_id
)
BEGIN
-- allow only table fields and set defaults for missing values
- :user_group_data = @FILTER(:user_group, user_group);
+ :user_group_data = @FILTER(:user_group, user_group)
INSERT INTO user_group
( @KEYS(:user_group_data) )
- VALUES ( :user_group_data );
+ VALUES ( :user_group_data ) RETURNING user_group_id;
- :user_group_content = @FILTER(:user_group, user_group_content);
+ :user_group_content = @FILTER(:user_group, user_group_content)
INSERT INTO user_group_content
@@ -91,7 +91,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :user_group_data = @FILTER(:user_group, user_group);
+ :user_group_data = @FILTER(:user_group, user_group)
UPDATE user_group
@@ -100,7 +100,7 @@
WHERE user_group_id = :user_group_id;
-- allow only table fields and set defaults for missing values
- :user_group_content = @FILTER(:user_group, user_group_content);
+ :user_group_content = @FILTER(:user_group, user_group_content)
UPDATE user_group_content
diff --git a/admin/sql/pgsql/user_wishlist.sql b/admin/sql/pgsql/user_wishlist.sql
index a3ca6f3..689547b 100644
--- a/admin/sql/pgsql/user_wishlist.sql
+++ b/admin/sql/pgsql/user_wishlist.sql
@@ -62,7 +62,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:user_wishlist, user_wishlist);
+ @FILTER(:user_wishlist, user_wishlist)
INSERT INTO user_wishlist
diff --git a/admin/sql/pgsql/vendor.sql b/admin/sql/pgsql/vendor.sql
index 4c5ef86..27b7aa9 100755
--- a/admin/sql/pgsql/vendor.sql
+++ b/admin/sql/pgsql/vendor.sql
@@ -47,7 +47,7 @@
-- SELECT * FROM vendor_option WHERE vendor_id = :vendor_id;
-- allow only table fields and set defaults for missing values
- @FILTER(:vendor, vendor);
+ @FILTER(:vendor, vendor)
UPDATE vendor
@@ -62,18 +62,19 @@
CREATE PROCEDURE add(
IN vendor ARRAY,
+ OUT fetch_one
OUT insert_id
)
BEGIN
-- allow only table fields and set defaults for missing values
- :vendor = @FILTER(:vendor, vendor);
+ :vendor = @FILTER(:vendor, vendor)
INSERT INTO vendor
( @KEYS(:vendor) )
- VALUES ( :vendor );
+ VALUES ( :vendor ) RETURNING vendor_id;
INSERT INTO vendor_to_site
diff --git a/admin/sql/pgsql/voucher.sql b/admin/sql/pgsql/voucher.sql
index 3f80ec8..689ce35 100755
--- a/admin/sql/pgsql/voucher.sql
+++ b/admin/sql/pgsql/voucher.sql
@@ -41,19 +41,19 @@
PROCEDURE add(
IN voucher ARRAY,
- OUT insert_id
+ OUT fetch_one
)
BEGIN
-- allow only table fields and set defaults for missing values
- :voucher_data = @FILTER(:voucher, voucher);
+ :voucher_data = @FILTER(:voucher, voucher)
INSERT INTO voucher
( @KEYS(:voucher_data) )
- VALUES ( :voucher_data );
+ VALUES ( :voucher_data ) RETURNING vendor_id;
END
@@ -66,7 +66,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- @FILTER(:voucher, voucher);
+ @FILTER(:voucher, voucher)
UPDATE voucher
diff --git a/admin/sql/pgsql/weight_type.sql b/admin/sql/pgsql/weight_type.sql
index cd95412..74a8ab3 100755
--- a/admin/sql/pgsql/weight_type.sql
+++ b/admin/sql/pgsql/weight_type.sql
@@ -58,22 +58,22 @@
PROCEDURE add(
IN weight_type ARRAY,
IN language_id INT,
- OUT insert_id
+ OUT fetch_one
OUT insert_id
)
BEGIN
-- allow only table fields and set defaults for missing values
- :weight_type_data = @FILTER(:weight_type, weight_type);
+ :weight_type_data = @FILTER(:weight_type, weight_type)
INSERT INTO weight_type
( @KEYS(:weight_type_data) )
- VALUES ( :weight_type_data);
+ VALUES ( :weight_type_data) RETURNING weight_type_id;
-- allow only table fields and set defaults for missing values
- :weight_type_content_data = @FILTER(:weight_type, weight_type_content);
+ :weight_type_content_data = @FILTER(:weight_type, weight_type_content)
INSERT INTO weight_type_content
@@ -93,7 +93,7 @@
BEGIN
-- allow only table fields and set defaults for missing values
- :weight_type_data = @FILTER(:weight_type, weight_type);
+ :weight_type_data = @FILTER(:weight_type, weight_type)
UPDATE weight_type
@@ -102,7 +102,7 @@
WHERE weight_type_id = :weight_type_id;
-- allow only table fields and set defaults for missing values
- :weight_type_content_data = @FILTER(:weight_type, weight_type_content);
+ :weight_type_content_data = @FILTER(:weight_type, weight_type_content)
UPDATE weight_type_content