Commit Graph

119 Commits

Author SHA1 Message Date
Eric Dowell 99597460f0 Use MySQL DEFAULT Clause/Constant (#319)
* Adding ability to use MySQL DEFAULT clause

Adding mysql.default option and documentation on special case for date.

Adding unit tests for Default Clause.

* Handle unsupported types, don't stringify numbers

* Adding note about unsupported column types.

* Update readme.
2017-08-08 20:40:40 -04:00
ssh24 b229bad2a5 Remove unnecessary line causing validation fail 2017-07-31 16:52:56 -04:00
biniam ad44168d4a isNewInstance undefined for after save hook
Since using REPLACE or INSERT...ON DUPLICATE KEY
statements both give us affected rows of 1 for a
new row or a row which got updated with the same
values, we make isNewInstance undefined on after
save hook for save, replaceOrCreate, and
updateOrCreate methods. Also, disable juggler
tests for that functionality.
2017-07-26 22:21:06 -04:00
biniam 7a7a34e77f upgrade eslint deps 2017-07-25 15:41:11 -04:00
Tetsuo Seto b0ac2509f1 Add DECIMAL to Number prop type 2017-06-26 21:21:50 -07:00
ssh24 2ded0f96eb Honor user specified datatype on PKs 2017-06-16 12:25:17 -04:00
biniam 134eeb24e2 Handle null vals properly
When converting null values
to database column values,
return null if column is
nullable, otherwise try
to cast it to the property
type, and if not, return
'null'.
2017-06-14 12:44:25 -04:00
ssh24 145d061e94 Allow case sensitive regex operation 2017-06-13 10:18:27 -04:00
biniam 3dad2bf4df switch long and lat for geopoint type
MySQL expects reverse order of latitude and longitude
from the way we use it in LoopBack, so switch the order
when saving and loading Point spatial type we use for
Point/GeoPoint.
2017-06-06 08:54:13 -04:00
Kevin Delisle c236eb068d discovery.test: fix discoverModels tests 2017-06-05 13:50:46 -04:00
Kevin Delisle 7d2f0751f6 Add http status code translations for errors
Errors will now have their status codes set based on the error
message returned by the MySQL driver.
2017-05-31 17:02:09 -04:00
ssh24 44083e43c1 Allow explicit data types
Override columnDataType function

Add test cases

Apply feedback

Use date type as explicit datatype
2017-05-31 14:42:53 -04:00
biniam 0187f0434b Revert "switch long and lat for geopoint type"
This reverts commit dd5bfb3f82.
2017-05-31 10:30:00 -04:00
biniam dd5bfb3f82 switch long and lat for geopoint type 2017-05-30 09:29:36 -04:00
Sakib Hasan 2ba88203f3 Escape index names (#280)
* Escape index names

* Add test cases
2017-05-19 11:57:06 -04:00
Sakib Hasan 18ddc84929 Fix docker setup (#279)
* Add support for host and database

* Order the optional parameters correctly
2017-05-15 13:38:30 -04:00
Joost de Bruijn c3a336c18d Adding support for fractional seconds. 2017-05-05 19:15:41 -04:00
Sergey Nosenko 72abcb8e9f fix compare of foreign keys for autoupdate (#272)
* fix compare of foreign keys for autoupdate

use mysql table name in case it is not equal model name

* fix column name lookup for fk definition

* fix ADD CONSTRAINT for multiple fk

if more the one foreign key added ADD CONSTRAINT
must be separated with comma but not with space as applySqlChanges do.

* fix duplicate foreign key creation on autoupdate

* fix entity name selection

* change join to toString as requested

* fix removing dropped keys

* fix linter issues

* add test case with columnName in foreign key

and isActual check after autoupdate

* uncommit accitenally commited test case
2017-05-05 19:13:23 -04:00
Kevin Delisle 31a7728dd0 Tests for datetime types 2017-05-02 17:46:21 -04:00
Sergey Nosenko ea33f557ab Properties with mysql custom "columnName" don't get autoupdated (#273)
* #250 fix column escaping for autoupdate

* Fix lint error
2017-04-27 17:31:20 -04:00
Sakib Hasan 345492e5b2 Revert PR #257 (#266) 2017-04-24 16:19:33 -04:00
Sergey Nosenko f2f0dac69d refactor date, timestamp and datetime data types handling (#257)
* refactor date, timestamp, datetime data-type

* reverse datatypes.test.js changes

* checking property.mysql.dataType

along with property.dataType for timestamp fields

* Fix PR linter

* moved test cases all under one test file

remove unnecessary test cases, unify setup procedures

* Fix sql mode before migration

Set sql mode to allow zero's on timestamp
Clean up code

* remove test cases with strings and DATE field type

* code cleanup as requested

* add accidentally deleted assert.ok(found)

* fix timeZone to timezone case in README.md

* Update readme with date type info
2017-04-18 10:13:46 -04:00
Sakib Hasan aa15ee553a Fix too many connection error (#261)
Disconnect db instance on TX test which makes multiple pool connection
2017-04-17 16:16:59 -04:00
juanra a8e22c5bff fix linting problems 2017-03-21 10:45:24 +01:00
Christiaan Westerbeek b67b57970f Return if column is generated or not (#198)
* Return if column is generated or not

Related to
https://github.com/strongloop/loopback-datasource-juggler/issues/899

* add pk for testgen table

* Fixe the double quotes around generated

as requested by @loay

* Fix commit linter

Block must not be padded by blank lines padded-blocks

* Code fixes to follow guide

* Should fix the tests failing

Test failing on the tableName (incorrect case)
2017-03-08 18:56:27 -05:00
Matthew Dickinson 5ba6687c7c Fix autoupdate to create foreign keys after tables
Updated the autoupdate function so that it collects foreign key
statements and runs them once all tables have been updated.
This prevents foreign keys being created before referenced tables.
2017-02-17 11:25:19 -05:00
Matthew Dickinson 04287f6a77 Added test to validate foreign key handling 2017-02-17 11:25:19 -05:00
Carl Fürstenberg 5383c4c0ff Follow mysql recommendations for handling booleans
Per http://dev.mysql.com/doc/refman/5.7/en/numeric-type-overview.html
`BOOL` and `BOOLEAN` is alias for `TINYINT(1)` thus we should make
sure discover can handle as such.

Introducing three flags:

* treatCHAR1AsString
  default false - treats CHAR(1) as a String instead of a Boolean
* treatBIT1AsBit
  default true - treats BIT(1) as a Boolean instead of a Binary
* treatTINYINT1AsTinyInt
  default true - treats TINYINT(1) as a Boolean instead of a Number

The default handling for CHAR(1) is legacy backward compability due to
custom to use a CHAR(1) to store 'Y', 'N', '0', '1', etc...
2017-01-11 19:44:50 -08:00
muhammad hasan 0f1b14b158 Fix expected column name when autoupdate
Fix mysql column name being ignored on dataType change or new column
being added
Fix mysql column name ignored if index changed

Add column name case on autoupdate test

Fix test case scheme error

Fix describe test
2016-12-12 10:06:18 -05:00
Loay Gewily fce2207da3 Fix CI Failures 2016-12-07 23:53:46 -05:00
Nicholas Duffy 18cffb98ab Add connectorCapabilities global object (#201) 2016-10-11 23:13:20 -07:00
Simon Ho 8ed53f6cfa Remove unused prefix for test env vars (#203)
* TEST_ prefix is not used by CI anymore and there for serve no purpose

* Part of overall goal to standardize env var injection to
  MODULE_VARNAME (ie. MYSQL_HOST for example) convention
2016-10-07 17:36:43 -07:00
Loay 6100a62461 Add CI fixes (#197) 2016-09-28 13:32:38 -07:00
Ron Lloyd 980151d0a8 Fixing lint errors 2016-09-13 22:21:11 -06:00
Ron Lloyd 0de8dc7c97 Tests for autoupdate mysql.columnName bug fix 2016-09-13 22:21:11 -06:00
Miroslav Bajtoš a9dc15c180 Explictly set forceId:false in test model 2016-09-05 16:01:31 +02:00
Simon Ho a004b03d0f Fix pretest and init test configs
Environment variables set in pretest.js and test/init.js were silently
being converted to Strings. For example, when TEST_MYSQL_USER is
undefined, it's value was automatically converted to the String
'undefined'. This is documented a side effect of assigning values to
process.env. See https://nodejs.org/api/process.html#process_process_env
for more details
2016-08-19 10:56:19 -07:00
deepakrkris 22c1700af8 Fix to configure model index in keys field
This is a fix for issue 109,for model indexes not configured
per strongloop documentation
2016-08-15 12:51:56 -04:00
Raymond Feng 5fec12a00c Merge pull request #179 from azatoth/zero_datetime
Add special handling of zero date/time entries
2016-08-11 09:03:14 -07:00
Loay 9c9b61e7dc Update eslint infrastructure 2016-08-10 20:04:26 -04:00
Ryan Graham 2533fe8404
test: use dump of original test DB as seed 2016-08-09 19:14:51 -07:00
Ryan Graham a798377f98
test: skip cardinality, update sub_part
Index cardinality is actually a metric that is based on MySQL analyzing
the table contents, so its value here has more to do with whether the
tests are running against a new table, an old table, or whether it has
any data in it.

The Sub_part field is similarly unimportant for the purposes of these
tests since it refers to indexing internals based on data type and
partial indexing.

See: https://dev.mysql.com/doc/refman/5.5/en/show-index.html
2016-08-09 19:14:51 -07:00
Ryan Graham 3954709bbc
test: accept alternate test db credentials
Allow the tests to run on ci.strongloop.com using the credentials that
are given there, but translate them to the form that is used on
cis-jenkins, which is actually the correct format.
2016-08-09 19:00:07 -07:00
Ryan Graham cb118de2cd
test: use should for easier debugging 2016-08-09 11:25:39 -07:00
Ryan Graham b965a31f77
test: account for mysql version differences
Some of the tests are based on default behaviour of MySQL 5.5 or older
which is not the same as 5.7 out of the box.
2016-08-09 11:25:38 -07:00
Ryan Graham 45491d1d90
test: match case with example/table.sql 2016-08-09 11:25:38 -07:00
Ryan Graham 5a7cac6852
test: separate assertions from test flow control 2016-08-09 11:25:38 -07:00
Ryan Graham 9ad29ddbaa
test: update tests to use example DB
Use should.match() so we can use case-insensitve regexp for properties
that change case depending on the server being tested against.
2016-08-09 11:25:38 -07:00
Ryan Graham ebb6e68f0e
test: fix undefined password
If no password is given, '+ password' stringifies to 'undefined', which
generates a URL that has 'undefined' as the password instead of leaving
out the password.
2016-08-05 10:54:21 -07:00
Carl Fürstenberg 1ee79768f2 Add special handling of zero date/time entries
Per MySQL docs
(http://dev.mysql.com/doc/refman/5.7/en/date-and-time-types.html):

  "MySQL permits you to store a “zero” value of '0000-00-00' as a
  “dummy date.” This is in some cases more convenient than using NULL
  values, and uses less data and index space. To disallow '0000-00-00',
  enable the NO_ZERO_DATE mode.

  “Zero” date or time values used through Connector/ODBC are converted
  automatically to NULL because ODBC cannot handle such values."

As we are not using Connector/ODBC we need to handle this ourself.
2016-07-29 14:59:24 +02:00