Skip to content

Commit

Permalink
update jdbc tests
Browse files Browse the repository at this point in the history
  • Loading branch information
roshan0708 committed Jan 19, 2025
1 parent a9fc896 commit 62ffbf4
Show file tree
Hide file tree
Showing 6 changed files with 162 additions and 132 deletions.
30 changes: 13 additions & 17 deletions test/JDBC/expected/money_aggregate-vu-cleanup.out
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,6 @@ GO
DROP TABLE IF EXISTS ResultTableNonMoney;
GO

-- Clean up UDT Test
DROP TABLE IF EXISTS ResultTableUDT;
GO

DROP TABLE IF EXISTS UDTMoneyTable;
GO

DROP TYPE IF EXISTS MoneyUDT;
GO

-- Clean up Check Constraint Test
DROP TABLE IF EXISTS ResultTableCheck;
GO
Expand All @@ -94,23 +84,29 @@ GO
DROP PROCEDURE IF EXISTS InsertMoney;
GO

-- Clean up Indexed View Test
DROP TABLE IF EXISTS ResultTableIndexedView;
GO

DROP VIEW IF EXISTS IndexedMoneyView;
GO

-- Clean up Computed Column Test
DROP TABLE IF EXISTS ResultTableComputed;
DROP TABLE IF EXISTS IndexedViewBaseTable;
GO

DROP TABLE IF EXISTS ComputedMoneyTable;
DROP TABLE IF EXISTS CurrencyMoneyTable;
GO

DROP TABLE IF EXISTS ResultTableCurrency1;
GO

-- Clean up Indexed View Test
DROP TABLE IF EXISTS ResultTableIndexedView;
DROP TABLE IF EXISTS ResultTableCurrency2;
GO

DROP VIEW IF EXISTS IndexedMoneyView;
DROP TABLE IF EXISTS ResultTableCurrency3;
GO

DROP TABLE IF EXISTS IndexedViewBaseTable;
DROP TABLE IF EXISTS ResultTableCurrency4;
GO

DROP TABLE IF EXISTS TestMoneyTable;
Expand Down
87 changes: 47 additions & 40 deletions test/JDBC/expected/money_aggregate-vu-prepare.out
Original file line number Diff line number Diff line change
Expand Up @@ -187,26 +187,6 @@ INTO ResultTableNonMoney
FROM NonMoneyTable;
GO

-- User-Defined Type Test
CREATE TYPE MoneyUDT FROM MONEY;
GO

CREATE TABLE UDTMoneyTable (
ID INT PRIMARY KEY,
Amount MoneyUDT
);
GO

INSERT INTO UDTMoneyTable VALUES (1, 100.00), (2, 200.00), (3, 300.00);
GO
~~ROW COUNT: 3~~


SELECT MAX(Amount) AS MaxUDTAmount
INTO ResultTableUDT
FROM UDTMoneyTable;
GO

-- Check Constraint Test
CREATE TABLE CheckConstraintMoneyTable (
ID INT PRIMARY KEY,
Expand Down Expand Up @@ -260,26 +240,6 @@ SELECT GetTotalMoney() AS TotalFunctionAmount
INTO ResultTableFunction;
GO

-- Computed Column Test
CREATE TABLE ComputedMoneyTable (
ID INT PRIMARY KEY,
BaseAmount MONEY,
TaxRate DECIMAL(5,2),
TotalAmount AS (BaseAmount * (1 + TaxRate/100)) PERSISTED
);
GO

INSERT INTO ComputedMoneyTable (ID, BaseAmount, TaxRate) VALUES
(1, 100.00, 10.00), (2, 200.00, 15.00), (3, 300.00, 20.00);
GO
~~ROW COUNT: 3~~


SELECT MAX(TotalAmount) AS MaxComputedAmount
INTO ResultTableComputed
FROM ComputedMoneyTable;
GO

-- Indexed View Test
CREATE TABLE IndexedViewBaseTable (
ID INT PRIMARY KEY,
Expand All @@ -304,3 +264,50 @@ SELECT MAX(Amount) AS MaxIndexedViewAmount
INTO ResultTableIndexedView
FROM IndexedMoneyView;
GO

-- Currency Symbol Test Cases
CREATE TABLE CurrencyMoneyTable (
ID INT IDENTITY(1,1),
Amount MONEY
);
GO

-- Insert values with different currency symbols
INSERT INTO CurrencyMoneyTable (Amount) VALUES
('$100.50'),
('£200.75'),
('€150.25'),
('¥300.00'),
('₹250.50'),
('CHF 175.25');
GO
~~ERROR (Code: 293)~~

~~ERROR (Message: invalid characters found: cannot cast value "CHF 175.25" to money)~~


-- Test different aggregations with currency symbols
SELECT MAX(Amount) AS MaxAmount
INTO ResultTableCurrency1
FROM CurrencyMoneyTable;
GO

SELECT MIN(Amount) AS MinAmount
INTO ResultTableCurrency2
FROM CurrencyMoneyTable;
GO

SELECT SUM(Amount) AS TotalAmount
INTO ResultTableCurrency3
FROM CurrencyMoneyTable;
GO

-- Test with mixed currency symbols in calculations
SELECT
MAX(Amount) AS MaxAmount,
MIN(Amount) AS MinAmount,
AVG(Amount) AS AvgAmount,
SUM(Amount) * 1.1 AS TotalWithMarkup
INTO ResultTableCurrency4
FROM CurrencyMoneyTable;
GO
47 changes: 33 additions & 14 deletions test/JDBC/expected/money_aggregate-vu-verify.out
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,6 @@ varchar#!#varchar#!#smallint#!#tinyint#!#tinyint
~~END~~


-- Verify UDT Test
EXEC get_column_info_p1 'ResultTableUDT';
GO
~~START~~
varchar#!#varchar#!#smallint#!#tinyint#!#tinyint
~~END~~


-- Verify Check Constraint Test
EXEC get_column_info_p1 'ResultTableCheck';
GO
Expand All @@ -176,20 +168,47 @@ totalfunctionamount#!#money#!#8#!#19#!#4
~~END~~


-- Verify Computed Column Test
EXEC get_column_info_p1 'ResultTableComputed';
-- Verify Indexed View Test
EXEC get_column_info_p1 'ResultTableIndexedView';
GO
~~START~~
varchar#!#varchar#!#smallint#!#tinyint#!#tinyint
maxcomputedamount#!#numeric#!#17#!#38#!#38
maxindexedviewamount#!#money#!#8#!#19#!#4
~~END~~


-- Verify Indexed View Test
EXEC get_column_info_p1 'ResultTableIndexedView';
-- Verify currency symbol test results
EXEC get_column_info_p1 'ResultTableCurrency1'
GO
~~START~~
varchar#!#varchar#!#smallint#!#tinyint#!#tinyint
maxindexedviewamount#!#money#!#8#!#19#!#4
maxamount#!#money#!#8#!#19#!#4
~~END~~


EXEC get_column_info_p1 'ResultTableCurrency2'
GO
~~START~~
varchar#!#varchar#!#smallint#!#tinyint#!#tinyint
minamount#!#money#!#8#!#19#!#4
~~END~~


EXEC get_column_info_p1 'ResultTableCurrency3'
GO
~~START~~
varchar#!#varchar#!#smallint#!#tinyint#!#tinyint
totalamount#!#money#!#8#!#19#!#4
~~END~~


EXEC get_column_info_p1 'ResultTableCurrency4'
GO
~~START~~
varchar#!#varchar#!#smallint#!#tinyint#!#tinyint
avgamount#!#money#!#8#!#19#!#4
maxamount#!#money#!#8#!#19#!#4
minamount#!#money#!#8#!#19#!#4
totalwithmarkup#!#numeric#!#17#!#38#!#38
~~END~~

30 changes: 13 additions & 17 deletions test/JDBC/input/money_aggregate-vu-cleanup.sql
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,6 @@ GO
DROP TABLE IF EXISTS ResultTableNonMoney;
GO

-- Clean up UDT Test
DROP TABLE IF EXISTS ResultTableUDT;
GO

DROP TABLE IF EXISTS UDTMoneyTable;
GO

DROP TYPE IF EXISTS MoneyUDT;
GO

-- Clean up Check Constraint Test
DROP TABLE IF EXISTS ResultTableCheck;
GO
Expand All @@ -94,23 +84,29 @@ GO
DROP PROCEDURE IF EXISTS InsertMoney;
GO

-- Clean up Indexed View Test
DROP TABLE IF EXISTS ResultTableIndexedView;
GO

DROP VIEW IF EXISTS IndexedMoneyView;
GO

-- Clean up Computed Column Test
DROP TABLE IF EXISTS ResultTableComputed;
DROP TABLE IF EXISTS IndexedViewBaseTable;
GO

DROP TABLE IF EXISTS ComputedMoneyTable;
DROP TABLE IF EXISTS CurrencyMoneyTable;
GO

DROP TABLE IF EXISTS ResultTableCurrency1;
GO

-- Clean up Indexed View Test
DROP TABLE IF EXISTS ResultTableIndexedView;
DROP TABLE IF EXISTS ResultTableCurrency2;
GO

DROP VIEW IF EXISTS IndexedMoneyView;
DROP TABLE IF EXISTS ResultTableCurrency3;
GO

DROP TABLE IF EXISTS IndexedViewBaseTable;
DROP TABLE IF EXISTS ResultTableCurrency4;
GO

DROP TABLE IF EXISTS TestMoneyTable;
Expand Down
79 changes: 43 additions & 36 deletions test/JDBC/input/money_aggregate-vu-prepare.sql
Original file line number Diff line number Diff line change
Expand Up @@ -173,24 +173,6 @@ INTO ResultTableNonMoney
FROM NonMoneyTable;
GO

-- User-Defined Type Test
CREATE TYPE MoneyUDT FROM MONEY;
GO

CREATE TABLE UDTMoneyTable (
ID INT PRIMARY KEY,
Amount MoneyUDT
);
GO

INSERT INTO UDTMoneyTable VALUES (1, 100.00), (2, 200.00), (3, 300.00);
GO

SELECT MAX(Amount) AS MaxUDTAmount
INTO ResultTableUDT
FROM UDTMoneyTable;
GO

-- Check Constraint Test
CREATE TABLE CheckConstraintMoneyTable (
ID INT PRIMARY KEY,
Expand Down Expand Up @@ -240,24 +222,6 @@ SELECT GetTotalMoney() AS TotalFunctionAmount
INTO ResultTableFunction;
GO

-- Computed Column Test
CREATE TABLE ComputedMoneyTable (
ID INT PRIMARY KEY,
BaseAmount MONEY,
TaxRate DECIMAL(5,2),
TotalAmount AS (BaseAmount * (1 + TaxRate/100)) PERSISTED
);
GO

INSERT INTO ComputedMoneyTable (ID, BaseAmount, TaxRate) VALUES
(1, 100.00, 10.00), (2, 200.00, 15.00), (3, 300.00, 20.00);
GO

SELECT MAX(TotalAmount) AS MaxComputedAmount
INTO ResultTableComputed
FROM ComputedMoneyTable;
GO

-- Indexed View Test
CREATE TABLE IndexedViewBaseTable (
ID INT PRIMARY KEY,
Expand All @@ -280,3 +244,46 @@ SELECT MAX(Amount) AS MaxIndexedViewAmount
INTO ResultTableIndexedView
FROM IndexedMoneyView;
GO

-- Currency Symbol Test Cases
CREATE TABLE CurrencyMoneyTable (
ID INT IDENTITY(1,1),
Amount MONEY
);
GO

-- Insert values with different currency symbols
INSERT INTO CurrencyMoneyTable (Amount) VALUES
('$100.50'),
('£200.75'),
('€150.25'),
('¥300.00'),
('₹250.50'),
('CHF 175.25');
GO

-- Test different aggregations with currency symbols
SELECT MAX(Amount) AS MaxAmount
INTO ResultTableCurrency1
FROM CurrencyMoneyTable;
GO

SELECT MIN(Amount) AS MinAmount
INTO ResultTableCurrency2
FROM CurrencyMoneyTable;
GO

SELECT SUM(Amount) AS TotalAmount
INTO ResultTableCurrency3
FROM CurrencyMoneyTable;
GO

-- Test with mixed currency symbols in calculations
SELECT
MAX(Amount) AS MaxAmount,
MIN(Amount) AS MinAmount,
AVG(Amount) AS AvgAmount,
SUM(Amount) * 1.1 AS TotalWithMarkup
INTO ResultTableCurrency4
FROM CurrencyMoneyTable;
GO
Loading

0 comments on commit 62ffbf4

Please sign in to comment.