Commit Graph

155 Commits

Author SHA1 Message Date
Sakib Hasan 2ba88203f3 Escape index names (#280)
* Escape index names

* Add test cases
2017-05-19 11:57:06 -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
Buck Bito cee6303454 Add new type DateString to fromColumnValue
To sync with loopback-datasource-juggler #1356
which introduces new Type: DateString
2017-05-01 19:38:41 -04:00
Buck Bito d0a88ef045 Remove String manipulations of Date objects
This commit contains all previous work after rebase went badly
RE: Pull Request requested by @kjdelisle regarding #149 following my
proposed solution "A" at #149 (comment).
As mentioned in the post linked above, this change allows the
underlying mysqljs/mysql module to handle Date object serialization
and removes the forced conversion of Dates to UTC Strings.
An opt-out fallback to forced coercion to UTC is included,
which was modeled after #265 from @darknos .

Old, squashed commits:
d0ea1d926eae04d0355109c87eef4eeec173f887
Legacy UTC date processing fallback credit: @darknos

a59dad7d7bd945895fb410a963cf5932b6a20f9e
Remove orphaned string functions

e8fdbdcfd4092f3d9e018f688d14def3e3ca9856
Incorporate @darknos expanded check for zero dates

abd4e0a7e9122f857974678a6b6ad87a19988f6f
Remove DATE manipulations in from/toColumnValue
2017-04-28 16:13:15 -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
Benjamin Schuster-Boeckler 70f0acadd4 Fix async.each in migration (#262) 2017-04-18 12:48:55 -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
juanra a8e22c5bff fix linting problems 2017-03-21 10:45:24 +01:00
ssh24 dc1e0d8050 Extract functions to base connector
move getAddModifyColumns and getDropColumns to base
2017-03-20 10:34:47 -04:00
ssh24 a02047b643 Refactor alter table
Include fk with autoupdate/migrate

Some tests are failing due to timeout, looking into it
should check actuality of dataSource fails, looking into it

Fix actuality of ds test

Fix autoupdate test timeout

Fix requested changes

Fix to checkOnly for isActual
2017-03-17 17:21:10 -04: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
ssh24 ab644d9fea Refactor migration methods
Fix timeout error on tests

Signed-off-by: Sakib Hasan <sshasan10@hotmail.com>

add showFields and showIndexes functions

Extract getTableStatus

Extract columnDataType to base connector
2017-03-02 15:49:30 -05:00
Loay 820bf03400 Refactor Discovery Methods 2017-02-28 16:06:51 -05:00
Matthew Dickinson 6848b72e22 Remove old TODO and commented out code 2017-02-18 21:10:04 -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 24c6b77a6f Add logging for errors encountered in discovery 2017-02-17 11:25:19 -05:00
Matthew Dickinson 0b04d461e4 Update signature for alterTable
Since alterTable is semi-public, the method now checks the arugments to
make sure that it still supports the old signature that doesn't include
actualFks
2017-02-17 11:25:19 -05:00
Matthew Dickinson d461d07f34 Limit foreign key creation current connector
Updated fk generation to make sure that it doesn't try to create
foreign keys linking to another DB/connector
2017-02-17 11:25:19 -05:00
Matthew Dickinson 4d20fa7746 Fix linting error 2017-02-17 11:25:19 -05:00
Matthew Dickinson 940032f4dd Update foreign key creation table name handling 2017-02-17 11:25:19 -05:00
Matthew Dickinson 782959cf20 Update alterTable to actually drop constraints 2017-02-17 11:25:19 -05:00
Matthew Dickinson 1324333ffd Add rough handling for automatic foreign keys
This handles basic creating/dropping of FKs based on model relations
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
Ron Lloyd a96d61fa9f Autoupdate mysql.columnName bug fix 2016-09-13 22:21:11 -06: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
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
Candy b55ae36e79 Add globalization 2016-07-28 17:20:03 -04:00
juehou 658635e72c Add function connect 2016-05-12 15:56:48 -04:00
Ryan Graham 340a4eb0f6
insert/update copyright notices 2016-05-03 16:52:03 -07:00
juehou 12cf967b7b Override other settings if url provided
Handle url in config
Override other settings if url provided
2016-04-06 23:31:23 -04:00
Amir Jafarian f572f920a4 Implement ReplaceOrCreate 2016-01-15 19:12:38 -05:00
Diogo Correia 8569c9812a Pass options to the execute command. 2015-10-11 17:08:25 +01:00
Simon Ho 22bebe3c4a Add support for RegExp operator 2015-07-28 17:24:31 -07:00
Raymond Feng 1bfaf1a783 Start to add transaction support 2015-05-18 12:02:25 -07:00
Raymond Feng c5d3b67bfe Fix the typo 2015-05-14 08:39:36 -07:00
Raymond Feng be54c1a407 Refactor the code to use base SqlConnector 2015-05-13 10:17:15 -07:00
Raymond Feng f6e4c228eb Return isNewInstance from upsert 2015-04-01 16:25:23 -07:00
Simon Ho ff538b09c8 Return count when updating or deleting models 2015-03-26 11:26:41 -07:00
Raymond Feng 1d2dd5e9fb Merge pull request #78 from strongloop/feature/allow-object-id
Allow models backed by MySQL to reference mongodb ObjectID
2015-03-09 15:55:43 -07:00
Raymond Feng fbe9ee078d Merge pull request #79 from partap/discovery-string-length
Query string length for schema in characters in addition to bytes
2015-03-09 15:55:24 -07:00
ulion f316b8ca7d Fix mysql neq for NULL value. 2015-03-08 22:57:36 +08:00
Partap Davis 0964a2634a replace dataLength instead of adding length property 2015-03-07 20:09:10 -07:00
Raymond Feng 634a0a94bc Allow models backed by MySQL to reference mongodb ObjectID 2015-03-04 22:55:33 -08:00
Partap Davis 1ee0c2f3bb Query string length for schema in characters in addition to bytes 2015-03-02 15:10:19 -07:00