This repository was archived by the owner on Dec 24, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed
src/ServiceStack.OrmLite.MySql
tests/ServiceStack.OrmLite.Tests Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -209,7 +209,7 @@ public string GetColumnDefinition(FieldDefinition fieldDef)
209
209
}
210
210
211
211
public override string SqlCurrency ( string fieldOrValue , string currencySymbol ) =>
212
- SqlConcat ( new [ ] { "'" + currencySymbol + "'" , "format (" + fieldOrValue + ",2)" } ) ;
212
+ SqlConcat ( new [ ] { "'" + currencySymbol + "'" , "cast (" + fieldOrValue + " as decimal(15 ,2))" } ) ;
213
213
214
214
protected MySqlConnection Unwrap ( IDbConnection db )
215
215
{
Original file line number Diff line number Diff line change @@ -13,6 +13,8 @@ public class Sqltest
13
13
14
14
public class SqlDialectTests : OrmLiteTestBase
15
15
{
16
+ //public SqlDialectTests() : base(Dialect.PostgreSql) {}
17
+
16
18
[ Test ]
17
19
public void Does_concat_values ( )
18
20
{
@@ -40,6 +42,15 @@ public void Does_format_currency()
40
42
db . DropAndCreateTable < Sqltest > ( ) ;
41
43
42
44
db . Insert ( new Sqltest { Value = 12 } ) ;
45
+
46
+ var sqlCurrency = db . GetDialectProvider ( ) . SqlCurrency ( "12.3456" ) ;
47
+ var result = db . Scalar < string > ( $ "SELECT { sqlCurrency } from sqltest") ;
48
+ Assert . That ( result , Is . EqualTo ( "$12.35" ) ) ;
49
+
50
+ sqlCurrency = db . GetDialectProvider ( ) . SqlCurrency ( "12.3456" , "£" ) ;
51
+ result = db . Scalar < string > ( $ "SELECT { sqlCurrency } from sqltest") ;
52
+ Assert . That ( result , Is . EqualTo ( "£12.35" ) ) ;
53
+
43
54
db . Insert ( new Sqltest { Value = 12.3 } ) ;
44
55
db . Insert ( new Sqltest { Value = 12.34 } ) ;
45
56
db . Insert ( new Sqltest { Value = 12.345 } ) ;
You can’t perform that action at this time.
0 commit comments