diff --git a/samples/samples-python/.pylintrc b/samples/samples-python/.pylintrc index cfba7c8bd..439fba0a1 100644 --- a/samples/samples-python/.pylintrc +++ b/samples/samples-python/.pylintrc @@ -13,4 +13,4 @@ file-header=# Copyright \(c\) Microsoft Corporation\. All rights reserved\.[\r\n # can either give multiple identifier separated by comma (,) or put this option # multiple time (only on the command line, not in the configuration file where # it should appear only once). -disable= R0801, W0108, W0613, C0103, C0114, C0115, C0116, E0401, C0301 \ No newline at end of file +disable= R0801, W0108, W0613, C0103, C0114, C0115, C0116, E0401, C0301, R0913, R0914 \ No newline at end of file diff --git a/samples/samples-python/Common/productcolumntypes.py b/samples/samples-python/Common/productcolumntypes.py deleted file mode 100644 index 4cebd0962..000000000 --- a/samples/samples-python/Common/productcolumntypes.py +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. - -import collections - -class ProductColumnTypes(collections.UserDict): - def __init__(self, productId, datetime, datetime2): - super().__init__() - self['ProductId'] = productId - self['Datetime'] = datetime - self['Datetime2'] = datetime2 diff --git a/test-outofproc/AddProductColumnTypes.cs b/test-outofproc/AddProductColumnTypes.cs index 8d26228b7..2355c13c9 100644 --- a/test-outofproc/AddProductColumnTypes.cs +++ b/test-outofproc/AddProductColumnTypes.cs @@ -27,8 +27,26 @@ public static ProductColumnTypes Run( var product = new ProductColumnTypes() { ProductId = int.Parse(queryStrings["productId"], null), + BigInt = int.MaxValue, + Bit = true, + DecimalType = 1.2345M, + Money = 1.23M, + Numeric = 1.2345M, + SmallInt = 0, + SmallMoney = 1.23M, + TinyInt = 1, + FloatType = 1.2, + Real = 1.2f, + Date = DateTime.UtcNow, Datetime = new SqlDateTime(DateTime.UtcNow).Value, - Datetime2 = DateTime.UtcNow + Datetime2 = DateTime.UtcNow, + DatetimeOffset = DateTime.UtcNow, + SmallDatetime = new SqlDateTime(DateTime.UtcNow).Value, + Time = DateTime.UtcNow.TimeOfDay, + CharType = "test", + Varchar = "test", + Nchar = "\u2649", + Nvarchar = "\u2649", }; return product; } diff --git a/test-outofproc/Product.cs b/test-outofproc/Product.cs index 16768cd42..301f5ec6e 100644 --- a/test-outofproc/Product.cs +++ b/test-outofproc/Product.cs @@ -93,24 +93,68 @@ public static List GetNewProductsRandomized(int num, int cost) return products; } } + public class ProductColumnTypes { public int ProductId { get; set; } + public long BigInt { get; set; } + + public bool Bit { get; set; } + + public decimal DecimalType { get; set; } + + public decimal Money { get; set; } + + public decimal Numeric { get; set; } + + public short SmallInt { get; set; } + + public decimal SmallMoney { get; set; } + + public short TinyInt { get; set; } + + public Double FloatType { get; set; } + + public Single Real { get; set; } + + public DateTime Date { get; set; } + public DateTime Datetime { get; set; } public DateTime Datetime2 { get; set; } + public DateTimeOffset DatetimeOffset { get; set; } + + public DateTime SmallDatetime { get; set; } + + public TimeSpan Time { get; set; } + + public string CharType { get; set; } + + public string Varchar { get; set; } + + public string Nchar { get; set; } + + public string Nvarchar { get; set; } + public override bool Equals(object obj) { if (obj is ProductColumnTypes) { var that = obj as ProductColumnTypes; - return this.ProductId == that.ProductId && this.Datetime == that.Datetime && this.Datetime2 == that.Datetime2; + return this.ProductId == that.ProductId && this.BigInt == that.BigInt && this.Bit == that.Bit && + this.DecimalType == that.DecimalType && this.Money == that.Money && this.Numeric == that.Numeric && + this.SmallInt == that.SmallInt && this.SmallMoney == that.SmallMoney && this.TinyInt == that.TinyInt && + this.FloatType == that.FloatType && this.Real == that.Real && this.Date == that.Date && + this.Datetime == that.Datetime && this.Datetime2 == that.Datetime2 && this.DatetimeOffset == that.DatetimeOffset && + this.SmallDatetime == that.SmallDatetime && this.Time == that.Time && this.CharType == that.CharType && + this.Varchar == that.Varchar && this.Nchar == that.Nchar && this.Nvarchar == that.Nvarchar; } return false; } } + public class ProductExtraColumns { public int ProductId { get; set; } diff --git a/test/Common/ProductColumnTypes.cs b/test/Common/ProductColumnTypes.cs index 7a8bd88be..1be1eca55 100644 --- a/test/Common/ProductColumnTypes.cs +++ b/test/Common/ProductColumnTypes.cs @@ -9,18 +9,65 @@ public class ProductColumnTypes { public int ProductId { get; set; } + public long BigInt { get; set; } + + public bool Bit { get; set; } + + public decimal DecimalType { get; set; } + + public decimal Money { get; set; } + + public decimal Numeric { get; set; } + + public short SmallInt { get; set; } + + public decimal SmallMoney { get; set; } + + public short TinyInt { get; set; } + + public Double FloatType { get; set; } + + public Single Real { get; set; } + + public DateTime Date { get; set; } + public DateTime Datetime { get; set; } public DateTime Datetime2 { get; set; } + public DateTimeOffset DatetimeOffset { get; set; } + + public DateTime SmallDatetime { get; set; } + + public TimeSpan Time { get; set; } + + public string CharType { get; set; } + + public string Varchar { get; set; } + + public string Nchar { get; set; } + + public string Nvarchar { get; set; } + public override bool Equals(object obj) { if (obj is ProductColumnTypes) { var that = obj as ProductColumnTypes; - return this.ProductId == that.ProductId && this.Datetime == that.Datetime && this.Datetime2 == that.Datetime2; + return this.ProductId == that.ProductId && this.BigInt == that.BigInt && this.Bit == that.Bit && + this.DecimalType == that.DecimalType && this.Money == that.Money && this.Numeric == that.Numeric && + this.SmallInt == that.SmallInt && this.SmallMoney == that.SmallMoney && this.TinyInt == that.TinyInt && + this.FloatType == that.FloatType && this.Real == that.Real && this.Date == that.Date && + this.Datetime == that.Datetime && this.Datetime2 == that.Datetime2 && this.DatetimeOffset == that.DatetimeOffset && + this.SmallDatetime == that.SmallDatetime && this.Time == that.Time && this.CharType == that.CharType && + this.Varchar == that.Varchar && this.Nchar == that.Nchar && this.Nvarchar == that.Nvarchar; } return false; } + + public override string ToString() + { + return $"[{this.ProductId}, {this.BigInt}, {this.Bit}, {this.DecimalType}, {this.Money}, {this.Numeric}, {this.SmallInt}, {this.SmallMoney}, {this.TinyInt}, {this.FloatType}, {this.Real}, {this.Date}, {this.Datetime}, {this.Datetime2}, {this.DatetimeOffset}, {this.SmallDatetime}, {this.Time}, {this.CharType}, {this.Varchar}, {this.Nchar}, {this.Nvarchar}]"; + } } } diff --git a/test/Database/Tables/ProductsColumnTypes.sql b/test/Database/Tables/ProductsColumnTypes.sql index a552b9db1..6ec8950b5 100644 --- a/test/Database/Tables/ProductsColumnTypes.sql +++ b/test/Database/Tables/ProductsColumnTypes.sql @@ -1,5 +1,23 @@ CREATE TABLE [ProductsColumnTypes] ( - [ProductId] [int] NOT NULL PRIMARY KEY, - [Datetime] [datetime], - [Datetime2] [datetime2] -) \ No newline at end of file + [ProductId] [int] NOT NULL PRIMARY KEY, + [BigInt] [bigint], + [Bit] [bit], + [DecimalType] [decimal](18,4), + [Money] [money], + [Numeric] [numeric](18,4), + [SmallInt] [smallint], + [SmallMoney] [smallmoney], + [TinyInt] [tinyint], + [FloatType] [float], + [Real] [real], + [Date] [date], + [Datetime] [datetime], + [Datetime2] [datetime2], + [DatetimeOffset] [datetimeoffset], + [SmallDatetime] [smalldatetime], + [Time] [time], + [CharType] [char](4), + [Varchar] [varchar](100), + [Nchar] [nchar](4), + [Nvarchar] [nvarchar](100), +) diff --git a/test/Integration/SqlInputBindingIntegrationTests.cs b/test/Integration/SqlInputBindingIntegrationTests.cs index c47416bd5..9177b9842 100644 --- a/test/Integration/SqlInputBindingIntegrationTests.cs +++ b/test/Integration/SqlInputBindingIntegrationTests.cs @@ -143,19 +143,30 @@ public async void GetProductsColumnTypesSerializationAsyncEnumerableTest(string this.StartFunctionHost(nameof(GetProductsColumnTypesSerializationAsyncEnumerable), lang, true); string datetime = "2022-10-20 12:39:13.123"; - ProductColumnTypes[] expectedResponse = new[] - { - new ProductColumnTypes() - { - ProductId = 999, - Datetime = DateTime.Parse(datetime), - Datetime2 = DateTime.Parse(datetime) - } - }; + ProductColumnTypes[] expectedResponse = JsonConvert.DeserializeObject("[{\"ProductId\":999,\"BigInt\":999,\"Bit\":false,\"DecimalType\":1.2345,\"Money\":1.2345,\"Numeric\":1.2345,\"SmallInt\":1,\"SmallMoney\":1.2345,\"TinyInt\":1,\"FloatType\":0.1,\"Real\":0.1,\"Date\":\"2022-10-20T00:00:00.000Z\",\"Datetime\":\"2022-10-20T12:39:13.123Z\",\"Datetime2\":\"2022-10-20T12:39:13.123Z\",\"DatetimeOffset\":\"2022-10-20T12:39:13.123Z\",\"SmallDatetime\":\"2022-10-20T12:39:00.000Z\",\"Time\":\"12:39:13.1230000\",\"CharType\":\"test\",\"Varchar\":\"test\",\"Nchar\":\"\uFFFD\u0020\u0020\u0020\",\"Nvarchar\":\"\uFFFD\"}]"); + this.ExecuteNonQuery("INSERT INTO [dbo].[ProductsColumnTypes] VALUES (" + - "999, " + // ProductId - $"CONVERT(DATETIME, '{datetime}'), " + // Datetime field - $"CONVERT(DATETIME2, '{datetime}'))"); // Datetime2 field + "999, " + // ProductId, + "999, " + // BigInt + "0, " + // Bit + "1.2345, " + // DecimalType + "1.2345, " + // Money + "1.2345, " + // Numeric + "1, " + // SmallInt + "1.2345, " + // SmallMoney + "1, " + // TinyInt + ".1, " + // FloatType + ".1, " + // Real + $"CONVERT(DATE, '{datetime}'), " + // Date + $"CONVERT(DATETIME, '{datetime}'), " + // Datetime + $"CONVERT(DATETIME2, '{datetime}'), " + // Datetime2 + $"CONVERT(DATETIMEOFFSET, '{datetime}'), " + // DatetimeOffset + $"CONVERT(SMALLDATETIME, '{datetime}'), " + // SmallDatetime + $"CONVERT(TIME, '{datetime}'), " + // Time + "'test', " + // CharType + "'test', " + // Varchar + "NCHAR(0xD84C), " + // Nchar + "NCHAR(0xD84C))"); // Nvarchar HttpResponseMessage response = await this.SendInputRequest("getproducts-columntypesserializationasyncenumerable", $"?culture={culture}"); // We expect the datetime and datetime2 fields to be returned in UTC format @@ -175,13 +186,31 @@ public async void GetProductsColumnTypesSerializationTest(SupportedLanguages lan string datetime = "2022-10-20 12:39:13.123"; this.ExecuteNonQuery("INSERT INTO [dbo].[ProductsColumnTypes] VALUES (" + - "999, " + // ProductId - $"CONVERT(DATETIME, '{datetime}'), " + // Datetime field - $"CONVERT(DATETIME2, '{datetime}'))"); // Datetime2 field + "999, " + // ProductId, + "999, " + // BigInt + "0, " + // Bit + "1.2345, " + // DecimalType + "1.2345, " + // Money + "1.2345, " + // Numeric + "1, " + // SmallInt + "1.2345, " + // SmallMoney + "1, " + // TinyInt + ".1, " + // FloatType + ".1, " + // Real + $"CONVERT(DATE, '{datetime}'), " + // Date + $"CONVERT(DATETIME, '{datetime}'), " + // Datetime + $"CONVERT(DATETIME2, '{datetime}'), " + // Datetime2 + $"CONVERT(DATETIMEOFFSET, '{datetime}'), " + // DatetimeOffset + $"CONVERT(SMALLDATETIME, '{datetime}'), " + // SmallDatetime + $"CONVERT(TIME, '{datetime}'), " + // Time + "'test', " + // CharType + "'test', " + // Varchar + "NCHAR(0xD84C), " + // Nchar + "NCHAR(0xD84C))"); // Nvarchar HttpResponseMessage response = await this.SendInputRequest("getproducts-columntypesserialization"); - // We expect the datetime and datetime2 fields to be returned in UTC format - ProductColumnTypes[] expectedResponse = JsonConvert.DeserializeObject("[{\"ProductId\":999,\"Datetime\":\"2022-10-20T12:39:13.123Z\",\"Datetime2\":\"2022-10-20T12:39:13.123Z\"}]"); + // We expect the date fields to be returned in UTC format + ProductColumnTypes[] expectedResponse = JsonConvert.DeserializeObject("[{\"ProductId\":999,\"BigInt\":999,\"Bit\":false,\"DecimalType\":1.2345,\"Money\":1.2345,\"Numeric\":1.2345,\"SmallInt\":1,\"SmallMoney\":1.2345,\"TinyInt\":1,\"FloatType\":0.1,\"Real\":0.1,\"Date\":\"2022-10-20T00:00:00.000Z\",\"Datetime\":\"2022-10-20T12:39:13.123Z\",\"Datetime2\":\"2022-10-20T12:39:13.123Z\",\"DatetimeOffset\":\"2022-10-20T12:39:13.123Z\",\"SmallDatetime\":\"2022-10-20T12:39:00.000Z\",\"Time\":\"12:39:13.1230000\",\"CharType\":\"test\",\"Varchar\":\"test\",\"Nchar\":\"\uFFFD\u0020\u0020\u0020\",\"Nvarchar\":\"\uFFFD\"}]"); string actualResponse = await response.Content.ReadAsStringAsync(); ProductColumnTypes[] actualProductResponse = JsonConvert.DeserializeObject(actualResponse); diff --git a/test/Integration/SqlOutputBindingIntegrationTests.cs b/test/Integration/SqlOutputBindingIntegrationTests.cs index cdb4e09d4..3e7e1c733 100644 --- a/test/Integration/SqlOutputBindingIntegrationTests.cs +++ b/test/Integration/SqlOutputBindingIntegrationTests.cs @@ -110,6 +110,7 @@ public void AddProductArrayTest(SupportedLanguages lang) /// The language to run the test against [Theory] [SqlInlineData()] + // Tracking issue here: https://github.com/Azure/azure-functions-sql-extension/issues/521 [UnsupportedLanguages(SupportedLanguages.Java)] public void AddProductColumnTypesTest(SupportedLanguages lang) { diff --git a/test/Integration/test-csharp/AddProductColumnTypes.cs b/test/Integration/test-csharp/AddProductColumnTypes.cs index 79fa416f9..cb2f61c77 100644 --- a/test/Integration/test-csharp/AddProductColumnTypes.cs +++ b/test/Integration/test-csharp/AddProductColumnTypes.cs @@ -13,7 +13,7 @@ public static class AddProductColumnTypes { /// /// This function is used to test compatability with converting various data types to their respective - /// SQL server types. + /// SQL server types. /// [FunctionName(nameof(AddProductColumnTypes))] public static IActionResult Run( @@ -23,8 +23,26 @@ public static IActionResult Run( product = new ProductColumnTypes() { ProductId = int.Parse(req.Query["productId"]), - Datetime = DateTime.UtcNow, - Datetime2 = DateTime.UtcNow + BigInt = int.MaxValue, + Bit = true, + DecimalType = 1.2345M, + Money = 1.23M, + Numeric = 1.2345M, + SmallInt = 0, + SmallMoney = 1.23M, + TinyInt = 1, + FloatType = 1.2, + Real = 1.2f, + Date = DateTime.Now, + Datetime = DateTime.Now, + Datetime2 = DateTime.Now, + DatetimeOffset = DateTime.Now, + SmallDatetime = DateTime.Now, + Time = DateTime.Now.TimeOfDay, + CharType = "test", + Varchar = "test", + Nchar = "\u2649", + Nvarchar = "\u2649", }; // Items were inserted successfully so return success, an exception would be thrown if there diff --git a/test/Integration/test-java/src/main/java/com/function/AddProductColumnTypes.java b/test/Integration/test-java/src/main/java/com/function/AddProductColumnTypes.java index c95a21f4c..b2e880d7c 100644 --- a/test/Integration/test-java/src/main/java/com/function/AddProductColumnTypes.java +++ b/test/Integration/test-java/src/main/java/com/function/AddProductColumnTypes.java @@ -17,7 +17,9 @@ import com.microsoft.azure.functions.sql.annotation.SQLOutput; import com.function.Common.ProductColumnTypes; +import java.math.BigDecimal; import java.sql.Timestamp; +import java.sql.Time; import java.util.Optional; public class AddProductColumnTypes { @@ -37,8 +39,26 @@ public HttpResponseMessage run( ProductColumnTypes p = new ProductColumnTypes( Integer.parseInt(request.getQueryParameters().get("productId")), + (long)999, + true, + new BigDecimal("1.2345"), + new BigDecimal("1.2345"), + new BigDecimal("1.2345"), + (short)1, + new BigDecimal("1.2345"), + (short)1, + 0.1, + 0.1, new Timestamp(System.currentTimeMillis()), - new Timestamp(System.currentTimeMillis())); + new Timestamp(System.currentTimeMillis()), + new Timestamp(System.currentTimeMillis()), + new Timestamp(System.currentTimeMillis()), + new Timestamp(System.currentTimeMillis()), + new Time(System.currentTimeMillis()).toString(), + "test", + "test", + "\u2649", + "\u2649"); product.setValue(p); // Items were inserted successfully so return success, an exception would be thrown if there diff --git a/test/Integration/test-java/src/main/java/com/function/Common/ProductColumnTypes.java b/test/Integration/test-java/src/main/java/com/function/Common/ProductColumnTypes.java index 7cfbb7a2c..2d13a40ae 100644 --- a/test/Integration/test-java/src/main/java/com/function/Common/ProductColumnTypes.java +++ b/test/Integration/test-java/src/main/java/com/function/Common/ProductColumnTypes.java @@ -6,25 +6,150 @@ package com.function.Common; +import java.math.BigDecimal; import java.sql.Timestamp; public class ProductColumnTypes { private int ProductId; + private long BigInt; + private boolean Bit; + private BigDecimal DecimalType; + private BigDecimal Money; + private BigDecimal Numeric; + private short SmallInt; + private BigDecimal SmallMoney; + private short TinyInt; + private double FloatType; + private double Real; + private Timestamp Date; private Timestamp Datetime; private Timestamp Datetime2; + private Timestamp DatetimeOffset; + private Timestamp SmallDatetime; + private String Time; + private String CharType; + private String Varchar; + private String Nchar; + private String Nvarchar; - public ProductColumnTypes(int productId, Timestamp datetime, Timestamp datetime2) { + + public ProductColumnTypes(int productId, long bigInt, boolean bit, BigDecimal decimalType, BigDecimal money, + BigDecimal numeric, short smallInt, BigDecimal smallMoney, short tinyInt, double floatType, double real, Timestamp date, + Timestamp datetime, Timestamp datetime2, Timestamp datetimeOffset, Timestamp smallDatetime, String time, String charType, + String varchar, String nchar, String nvarchar) { ProductId = productId; + BigInt = bigInt; + Bit = bit; + DecimalType = decimalType; + Money = money; + Numeric = numeric; + SmallInt = smallInt; + SmallMoney = smallMoney; + TinyInt = tinyInt; + FloatType = floatType; + Real = real; + Date = date; Datetime = datetime; Datetime2 = datetime2; + DatetimeOffset = datetimeOffset; + SmallDatetime = smallDatetime; + Time = time; + CharType = charType; + Varchar = varchar; + Nchar = nchar; + Nvarchar = nvarchar; } public int getProductId() { return ProductId; } - public void setProductId(int productId) { - ProductId = productId; + public long getBigint() { + return BigInt; + } + + public void setBigint(long bigInt) { + BigInt = bigInt; + } + + public boolean setBit() { + return Bit; + } + + public void setBit(boolean bit) { + Bit = bit; + } + + public BigDecimal getDecimalType() { + return DecimalType; + } + + public void setDecimalType(BigDecimal decimalType) { + DecimalType = decimalType; + } + + public BigDecimal getMoney() { + return Money; + } + + public void setMoney(BigDecimal money) { + Money = money; + } + + public BigDecimal getNumeric() { + return Numeric; + } + + public void setNumeric(BigDecimal numeric) { + Numeric = numeric; + } + + public short getSmallInt() { + return SmallInt; + } + + public void setSmallInt(short smallInt) { + SmallInt = smallInt; + } + + public BigDecimal getSmallMoney() { + return SmallMoney; + } + + public void setSmallMoney(BigDecimal smallMoney) { + SmallMoney = smallMoney; + } + + public short getTinyInt() { + return TinyInt; + } + + public void setTinyInt(short tinyInt) { + TinyInt = tinyInt; + } + + public double getFloatType() { + return FloatType; + } + + public void setFloatType(double floatType) { + FloatType = floatType; + } + + public double getReal() { + return Real; + } + + public void setReal(double real) { + Real = real; + } + + public Timestamp getDate() { + return Date; + } + + public void setDate(Timestamp date) { + Date = date; } public Timestamp getDatetime() { @@ -42,4 +167,60 @@ public Timestamp getDatetime2() { public void setDatetime2(Timestamp datetime2) { Datetime2 = datetime2; } -} + + public Timestamp getDatetimeOffset() { + return DatetimeOffset; + } + + public void setDatetimeOffset(Timestamp datetimeOffset) { + DatetimeOffset = datetimeOffset; + } + + public Timestamp getSmallDatetime() { + return SmallDatetime; + } + + public void setSmallDatetime(Timestamp smallDatetime) { + SmallDatetime = smallDatetime; + } + + public String getTime() { + return Time; + } + + public void setTime(String time) { + Time = time; + } + + public String getCharType() { + return CharType; + } + + public void setCharType(String charType) { + CharType = charType; + } + + public String getVarchar() { + return Varchar; + } + + public void setVarchar(String varchar) { + Varchar = varchar; + } + + public String getNchar() { + return Nchar; + } + + public void setNchar(String nchar) { + Nchar = nchar; + } + + public String getNvarchar() { + return Nvarchar; + } + + public void setNvarchar(String nvarchar) { + Nvarchar = nvarchar; + } +} \ No newline at end of file diff --git a/test/Integration/test-java/src/main/java/com/function/GetProductsColumnTypesSerialization.java b/test/Integration/test-java/src/main/java/com/function/GetProductsColumnTypesSerialization.java index 0ec538b96..0fae41c0e 100644 --- a/test/Integration/test-java/src/main/java/com/function/GetProductsColumnTypesSerialization.java +++ b/test/Integration/test-java/src/main/java/com/function/GetProductsColumnTypesSerialization.java @@ -47,11 +47,15 @@ public HttpResponseMessage run( mapper.setDateFormat(df); for (ProductColumnTypes product : products) { // Convert the datetimes to UTC (Java worker returns the datetimes in local timezone) + long date = product.getDate().getTime(); long datetime = product.getDatetime().getTime(); long datetime2 = product.getDatetime2().getTime(); + long smallDateTime = product.getSmallDatetime().getTime(); int offset = Calendar.getInstance().getTimeZone().getOffset(product.getDatetime().getTime()); + product.setDate(new Timestamp(date - offset)); product.setDatetime(new Timestamp(datetime - offset)); product.setDatetime2(new Timestamp(datetime2 - offset)); + product.setSmallDatetime(new Timestamp(smallDateTime - offset)); context.getLogger().log(Level.INFO, mapper.writeValueAsString(product)); } return request.createResponseBuilder(HttpStatus.OK).header("Content-Type", "application/json").body(mapper.writeValueAsString(products)).build(); diff --git a/test/Integration/test-js/AddProductColumnTypes/index.js b/test/Integration/test-js/AddProductColumnTypes/index.js index 7e0e777b9..6b15e3df3 100644 --- a/test/Integration/test-js/AddProductColumnTypes/index.js +++ b/test/Integration/test-js/AddProductColumnTypes/index.js @@ -8,8 +8,26 @@ module.exports = async function (context, req) { const product = { "ProductId": req.query.productId, + "BigInt": 999, + "Bit": true, + "DecimalType": 1.2345, + "Money": 1.2345, + "Numeric": 1.2345, + "SmallInt": 1, + "SmallMoney": 1.2345, + "TinyInt": 1, + "FloatType": 0.1, + "Real": 0.1, + "Date": new Date().toISOString(), "Datetime": new Date().toISOString(), - "Datetime2": new Date().toISOString() + "Datetime2": new Date().toISOString(), + "DatetimeOffset": new Date().toISOString(), + "SmallDatetime": new Date().toISOString(), + "Time": new Date().toISOString(), + "CharType": "test", + "Varchar": "test", + "Nchar": "\u2649", + "Nvarchar": "\u2649" }; context.bindings.product = JSON.stringify(product); diff --git a/test/Integration/test-powershell/AddProductColumnTypes/run.ps1 b/test/Integration/test-powershell/AddProductColumnTypes/run.ps1 index 0eb303d1d..2082a7239 100644 --- a/test/Integration/test-powershell/AddProductColumnTypes/run.ps1 +++ b/test/Integration/test-powershell/AddProductColumnTypes/run.ps1 @@ -9,19 +9,37 @@ param($Request, $TriggerMetadata) # Write to the Azure Functions log stream. Write-Host "PowerShell function with SQL Output Binding processed a request." -# Note that this expects the body to be a JSON object or array of objects +# Note that this expects the body to be a JSON object or array of objects # which have a property matching each of the columns in the table to upsert to. -$req_query = @{ +$req_query = @{ ProductId=$Request.QUERY.productId; - Datetime=Get-Date -AsUTC -format s; - Datetime2=Get-Date -AsUTC; + BigInt=999; + Bit=$true; + DecimalType=1.2345; + Money=1.2345; + Numeric=1.2345; + SmallInt=1; + SmallMoney=1.2345; + TinyInt=1; + FloatType=0.1; + Real=0.1; + Date=Get-Date -AsUTC -Format "yyyy-MM-dd"; + Datetime=Get-Date -AsUTC -Format "yyyy-MM-ddTHH:mm:ss"; + Datetime2=Get-Date -AsUTC -Format "yyyy-MM-ddTHH:mm:ss"; + DatetimeOffset=Get-Date -AsUTC -Format "yyyy-MM-ddTHH:mm:sszzz"; + SmallDatetime=Get-Date -AsUTC -Format "yyyy-MM-ddTHH:mm:ss"; + Time=Get-Date -AsUTC -Format "HH:mm:ss"; + CharType="test"; + Varchar="test"; + Nchar="\u2649"; + Nvarchar="\u2649"; }; -# Assign the value we want to pass to the SQL Output binding. +# Assign the value we want to pass to the SQL Output binding. # The -Name value corresponds to the name property in the function.json for the binding Push-OutputBinding -Name product -Value $req_query -# Assign the value to return as the HTTP response. +# Assign the value to return as the HTTP response. # The -Name value matches the name property in the function.json for the binding Push-OutputBinding -Name response -Value ([HttpResponseContext]@{ StatusCode = [HttpStatusCode]::OK diff --git a/test/Integration/test-python/AddProductColumnTypes/__init__.py b/test/Integration/test-python/AddProductColumnTypes/__init__.py index f57c74c70..727eecbf9 100644 --- a/test/Integration/test-python/AddProductColumnTypes/__init__.py +++ b/test/Integration/test-python/AddProductColumnTypes/__init__.py @@ -9,7 +9,28 @@ # This function is used to test compatibility with converting various data types to their respective # SQL server types. def main(req: func.HttpRequest, product: func.Out[func.SqlRow]) -> func.HttpResponse: - productColumnTypes = func.SqlRow(ProductColumnTypes(req.params["productId"], datetime.datetime.utcnow().isoformat("T", "milliseconds"), datetime.datetime.utcnow().isoformat("T", "milliseconds"))) + productColumnTypes = func.SqlRow(ProductColumnTypes(req.params["productId"], + 999, + True, + 1.2345, + 1.2345, + 1.2345, + 1, + 1.2345, + 1, + 0.1, + 0.1, + datetime.datetime.utcnow().isoformat("T", "milliseconds"), + datetime.datetime.utcnow().isoformat("T", "milliseconds"), + datetime.datetime.utcnow().isoformat("T", "milliseconds"), + datetime.datetime.utcnow().isoformat("T", "milliseconds"), + datetime.datetime.utcnow().isoformat("T", "milliseconds"), + datetime.datetime.utcnow().isoformat("T", "milliseconds"), + "test", + "test", + "\u2649", + "\u2649") + ) product.set(productColumnTypes) return func.HttpResponse( diff --git a/test/Integration/test-python/Common/productcolumntypes.py b/test/Integration/test-python/Common/productcolumntypes.py index 4cebd0962..f24a08dda 100644 --- a/test/Integration/test-python/Common/productcolumntypes.py +++ b/test/Integration/test-python/Common/productcolumntypes.py @@ -4,8 +4,29 @@ import collections class ProductColumnTypes(collections.UserDict): - def __init__(self, productId, datetime, datetime2): + def __init__(self, productId, bigInt, bit, decimalType, money, numeric, smallInt, + smallMoney, tinyInt, floatType, real, date, datetime, datetime2, datetimeOffset, + smallDatetime, time, charType, varchar, nchar, nvarchar): super().__init__() self['ProductId'] = productId + self['BigInt'] = bigInt + self['Bit'] = bit + self['DecimalType'] = decimalType + self['Money'] = money + self['Numeric'] = numeric + self['SmallInt'] = smallInt + self['SmallMoney'] = smallMoney + self['TinyInt'] = tinyInt + self['FloatType'] = floatType + self['Real'] = real + self['Date'] = date self['Datetime'] = datetime self['Datetime2'] = datetime2 + self['DatetimeOffset'] = datetimeOffset + self['SmallDatetime'] = smallDatetime + self['Time'] = time + self['CharType'] = charType + self['Varchar'] = varchar + self['Nchar'] = nchar + self['Nvarchar'] = nvarchar +