watermarkchurch / wcc-contentful

An alternative to Contentful's contentful.rb ruby client, contentful_model, and contentful_rails gems all in one.
MIT License
2 stars 1 forks source link

Fix Syntax Issue where Postgress requires parameters listed in function name, effects only pre version 10 #64

Closed reidcooper closed 6 years ago

reidcooper commented 6 years ago

I am running into issues when running my specs on SemaphoreCI.

There supported version of Postgres is 9.6.6, https://semaphoreci.com/docs/supported-stack.html

According to this Stackoverflow post, Postgres 10 does not require the parameters listed when trying to drop a function.

However, for the sake of compatibility, I would like to add the parameters to the drop function.

gburgett commented 6 years ago

I can't figure out how to get CircleCI to run this PR. @jpowell ideas? I might just download it and run the tests locally

gburgett commented 6 years ago

Worked locally via the CircleCI build tool with circleci build

I'm good to merge it. Thanks @reidcooper!

WCC::Contentful
  has a version number
  .init
    raises argument error if not configured
    content_delivery = direct
D, [2018-08-06T14:21:30.247580 #11348] DEBUG -- : [httplog] GET https://api.contentful.com/spaces/test1xab/content_types?limit=1000 completed with status code 200 in 0.006114198011346161 seconds
D, [2018-08-06T14:21:30.308832 #11348] DEBUG -- : [httplog] GET https://cdn.contentful.com/spaces/test1xab/entries/JhYhSfZPAOMqsaK8cYOUK?locale=%2A completed with status code 200 in 0.002805905998684466 seconds
      builds out store using CDNAdapter
    with management token
D, [2018-08-06T14:21:30.319090 #11348] DEBUG -- : [httplog] GET https://api.contentful.com/spaces/test1xab/content_types?limit=1000 completed with status code 200 in 0.0074641809915192425 seconds
      should populate models via Management API cache
    content_delivery = lazy_sync
D, [2018-08-06T14:21:30.446443 #11348] DEBUG -- : [httplog] GET https://api.contentful.com/spaces/test1xab/content_types?limit=1000 completed with status code 200 in 0.020033288004924543 seconds
D, [2018-08-06T14:21:30.554265 #11348] DEBUG -- : [httplog] GET https://cdn.contentful.com/spaces/test1xab/entries/6y9DftpiYoA4YiKg2CgoUU?locale=%2A completed with status code 200 in 0.005059393006376922 seconds
D, [2018-08-06T14:21:30.560613 #11348] DEBUG -- : [httplog] GET https://cdn.contentful.com/spaces/test1xab/entries/1IJEXB4AKEqQYEm4WuceG2?locale=%2A completed with status code 200 in 0.00456808099988848 seconds
      should call out to CDN for first calls only
D, [2018-08-06T14:21:30.570719 #11348] DEBUG -- : [httplog] GET https://api.contentful.com/spaces/test1xab/content_types?limit=1000 completed with status code 200 in 0.006023925001500174 seconds
      should error when trying to use preview api
    without management token
D, [2018-08-06T14:21:30.681944 #11348] DEBUG -- : [httplog] GET https://cdn.contentful.com/spaces/test1xab/content_types?limit=1000 completed with status code 200 in 0.01937788700161036 seconds
      should populate models via CDN client
  .init with preview token
    with preview token
D, [2018-08-06T14:21:30.763426 #11348] DEBUG -- : [httplog] GET https://cdn.contentful.com/spaces/test1xab/content_types?limit=1000 completed with status code 200 in 0.00612348600407131 seconds
D, [2018-08-06T14:21:30.851809 #11348] DEBUG -- : [httplog] GET https://cdn.contentful.com/spaces/test1xab/entries?locale=%2A&content_type=redirect&fields.slug.en-US=published-redirect completed with status code 200 in 0.007238619000418112 seconds
      should find published content in Contentful if preview is set to false
D, [2018-08-06T14:21:30.859268 #11348] DEBUG -- : [httplog] GET https://cdn.contentful.com/spaces/test1xab/content_types?limit=1000 completed with status code 200 in 0.005033073000959121 seconds
D, [2018-08-06T14:21:30.956246 #11348] DEBUG -- : [httplog] GET https://preview.contentful.com/spaces/test1xab/entries?locale=%2A&content_type=redirect&fields.slug.en-US=draft-redirect completed with status code 200 in 0.006944961001863703 seconds
      should find draft content in Contentful if preview is set to true
D, [2018-08-06T14:21:30.962152 #11348] DEBUG -- : [httplog] GET https://cdn.contentful.com/spaces/test1xab/content_types?limit=1000 completed with status code 200 in 0.003212166004232131 seconds
D, [2018-08-06T14:21:31.055334 #11348] DEBUG -- : [httplog] GET https://cdn.contentful.com/spaces/test1xab/entries?locale=%2A&content_type=redirect&fields.slug.en-US=draft-redirect completed with status code 200 in 0.006927733003976755 seconds
      should not find draft content in Contentful if preview is set to false
D, [2018-08-06T14:21:31.061001 #11348] DEBUG -- : [httplog] GET https://cdn.contentful.com/spaces/test1xab/content_types?limit=1000 completed with status code 200 in 0.00316571700386703 seconds
D, [2018-08-06T14:21:31.141563 #11348] DEBUG -- : [httplog] GET https://preview.contentful.com/spaces/test1xab/entries?locale=%2A&content_type=redirect&fields.slug.en-US=published-redirect completed with status code 200 in 0.007206944996141829 seconds
      should find published content in Contentful if preview is set to true
  .configure
    when passed VALID configuration arguments
      should return a Contentful config object populated with the valid values given
    invalid config
      should error when access token is nil
      should error when trying to use sync with environments
      should error when space is nil
  .validate_models!
    fails validation if menus not present
    validates successfully if all types present

WCC::Contentful::Store::LazyCacheStore
D, [2018-08-06T14:21:31.474484 #11348] DEBUG -- : [httplog] GET https://cdn.contentful.com/spaces/test1xab/entries?locale=%2A&content_type=menu&fields.name.en-US=Main+Menu completed with status code 200 in 0.004320734005887061 seconds
D, [2018-08-06T14:21:31.478817 #11348] DEBUG -- : [httplog] GET https://cdn.contentful.com/spaces/test1xab/entries?locale=%2A&content_type=menu&fields.name.en-US=Main+Menu completed with status code 200 in 0.0030877039971528575 seconds
  delegates #find_all to the API and does not cache them
  #index
    does not remove if "DeletedEntry" revision is lower
    removes a "DeletedEntry"
    updates the cache if the item was recently accessed
    does not overwrite an entry if revision is lower
    updates an "Entry" when exists
D, [2018-08-06T14:21:31.492375 #11348] DEBUG -- : [httplog] GET https://cdn.contentful.com/spaces/test1xab/entries/47PsST8EicKgWIWwK2AsW6?locale=%2A completed with status code 200 in 0.0047965390112949535 seconds
    does not update the cache if the item has not been accessed recently
  #find
    returns stored token if it exists in the cache
D, [2018-08-06T14:21:31.503230 #11348] DEBUG -- : [httplog] GET https://cdn.contentful.com/spaces/test1xab/entries/xxxxxxxxxxxxxxxxxxasdf?locale=%2A completed with status code 404 in 0.005542677012272179 seconds
D, [2018-08-06T14:21:31.508116 #11348] DEBUG -- : [httplog] GET https://cdn.contentful.com/spaces/test1xab/assets/xxxxxxxxxxxxxxxxxxasdf?locale=%2A completed with status code 404 in 0.003780148006626405 seconds
    finds and caches nils from the backing API
    does not hit the backing API for sync token
D, [2018-08-06T14:21:31.513797 #11348] DEBUG -- : [httplog] GET https://cdn.contentful.com/spaces/test1xab/entries/47PsST8EicKgWIWwK2AsW6?locale=%2A completed with status code 200 in 0.0027671069983625785 seconds
    finds and caches items from the backing API

WCC::Contentful::WebhookController
  receive
    continues running jobs even if one fails
    returns 204 no content on success
    denies requests with bad content type
    denies requests not conforming to contentful object structure
    denies requests without HTTP BASIC auth
    runs a sync on success
    runs configured jobs on success
    denies requests with bad HTTP BASIC auth

WCC::Contentful::Store::MemoryStore
  returns all keys
  behaves like contentful store
    #index
      updates an "Entry" when exists
      does not remove if "DeletedAsset" revision is lower
      updates an "Asset" when exists
      removes a "DeletedAsset"
      does not overwrite an asset if revision is lower
      stores an "Asset"
      does not overwrite an entry if revision is lower
      does not remove if "DeletedEntry" revision is lower
      stores an "Entry"
      removes a "DeletedEntry"
    #set/#find
      stores and finds data by ID
      find returns nil if key doesnt exist
      set returns prior value if exists
    #find_all
      find_all filters on content type
      find_all can apply filter query
      filter query eq can find value in array
    #find_by
      recursively resolves links if include > 0
      returns nil when cant find content type
      filter object can find value in array
      finds first of content type
      stops resolving links at include depth
      can apply filter object
    #delete
      deletes an item out of the store
      returns nil if item doesn't exist

WCC::Contentful::Store::PostgresStore
NOTICE:  table "contentful_raw" does not exist, skipping
NOTICE:  function upsert_entry(pg_catalog.varchar,jsonb) does not exist, skipping
  returns all keys
  behaves like contentful store
    #find_all
      find_all filters on content type
      find_all can apply filter query
      filter query eq can find value in array
    #delete
      deletes an item out of the store
      returns nil if item doesn't exist
    #set/#find
      set returns prior value if exists
      stores and finds data by ID
      find returns nil if key doesnt exist
    #find_by
      finds first of content type
      stops resolving links at include depth
      can apply filter object
      returns nil when cant find content type
      filter object can find value in array
      recursively resolves links if include > 0
    #index
      stores an "Asset"
      does not remove if "DeletedAsset" revision is lower
      removes a "DeletedEntry"
      updates an "Asset" when exists
      does not overwrite an entry if revision is lower
      updates an "Entry" when exists
      removes a "DeletedAsset"
      does not remove if "DeletedEntry" revision is lower
      does not overwrite an asset if revision is lower
      stores an "Entry"

WCC::Contentful::ModelBuilder
  returns empty array if find_all finds nothing
  builds models from loaded types
  resolves linked types
  resolves date times and json blobs
  resolves numeric fields
  handles nil linked types
  errors fast if ID is wrong content type
  stores backreference on linked type context
  finds by ID on derived class
  makes ID of linked types accessible
  finds types by content type
  returns nil if cannot find ID
  returns nil if find_by finds nothing
  finds with filter
  linked arrays are empty when no links found
  finds single item with filter
  finds types by ID
  resolves linked assets
  resolves coordinates
  model class registry
    class registration can be overridden in the class definition
    registered class is returned when a link is expanded
    re-raises NameError if the class def itself raises a name error
    class can be registered by being the first subclass
    does not use loaded class if it does not inherit WCC::Contentful::Model
    does not use loaded class if it does not exist
    loads app-defined constant using const_missing
  model subclasses
    can execute .find_all
    responds to .content_type_definition
    can execute .find_by
    responds to .content_type
    raises meaningful error when constant not defined
    can execute .find
  with options
    find_by preloads links when include param > 0

WCC::Contentful::Configuration
  #validate!
    errors when non-master environment combined with sync delivery strategy
    errors when non-callable object given to webhook_jobs
  #content_delivery
    allows setting a store class with parameters to store=
    allows setting a custom store to store=
    raises error when setting a store to content_delivery
    raises error when setting invalid content delivery method
    eager sync
      uses provided store
      errors when using a bad store
NOTICE:  relation "contentful_raw" already exists, skipping
NOTICE:  relation "contentful_raw_value_type" already exists, skipping
NOTICE:  relation "contentful_raw_value_content_type" already exists, skipping
      selects store from symbol
    direct
      uses CDN adapter
    lazy sync
      looks up cache from activesupport
      uses provided cache

WCC::Contentful::SimpleClient
  initialize
/home/circleci/project/spec/wcc/contentful/simple_client_spec.rb:50: warning: already initialized constant WCC::Contentful::SimpleClient::ADAPTERS
/home/circleci/project/lib/wcc/contentful/simple_client.rb:64: warning: previous definition of ADAPTERS was here
/home/circleci/project/spec/wcc/contentful/simple_client_spec.rb:15: warning: already initialized constant WCC::Contentful::SimpleClient::ADAPTERS
/home/circleci/project/spec/wcc/contentful/simple_client_spec.rb:50: warning: previous definition of ADAPTERS was here
    loads proc as adapter
/home/circleci/project/spec/wcc/contentful/simple_client_spec.rb:23: warning: already initialized constant WCC::Contentful::SimpleClient::ADAPTERS
/home/circleci/project/spec/wcc/contentful/simple_client_spec.rb:15: warning: previous definition of ADAPTERS was here
/home/circleci/project/spec/wcc/contentful/simple_client_spec.rb:15: warning: already initialized constant WCC::Contentful::SimpleClient::ADAPTERS
/home/circleci/project/spec/wcc/contentful/simple_client_spec.rb:23: warning: previous definition of ADAPTERS was here
    fails to load when no adapter gem found
/home/circleci/project/spec/wcc/contentful/simple_client_spec.rb:37: warning: already initialized constant WCC::Contentful::SimpleClient::ADAPTERS
/home/circleci/project/spec/wcc/contentful/simple_client_spec.rb:15: warning: previous definition of ADAPTERS was here
/home/circleci/project/spec/wcc/contentful/simple_client_spec.rb:15: warning: already initialized constant WCC::Contentful::SimpleClient::ADAPTERS
/home/circleci/project/spec/wcc/contentful/simple_client_spec.rb:37: warning: previous definition of ADAPTERS was here
    fails to load when gem is wrong version
/home/circleci/project/spec/wcc/contentful/simple_client_spec.rb:67: warning: already initialized constant WCC::Contentful::SimpleClient::ADAPTERS
/home/circleci/project/spec/wcc/contentful/simple_client_spec.rb:15: warning: previous definition of ADAPTERS was here
/home/circleci/project/spec/wcc/contentful/simple_client_spec.rb:70: warning: already initialized constant WCC::Contentful::SimpleClient::ADAPTERS
/home/circleci/project/spec/wcc/contentful/simple_client_spec.rb:67: warning: previous definition of ADAPTERS was here
/home/circleci/project/spec/wcc/contentful/simple_client_spec.rb:15: warning: already initialized constant WCC::Contentful::SimpleClient::ADAPTERS
/home/circleci/project/spec/wcc/contentful/simple_client_spec.rb:70: warning: previous definition of ADAPTERS was here
    fails to load when adapter is not invokeable
  get
    can query entries with query param
D, [2018-08-06T14:21:34.681754 #11348] DEBUG -- : [httplog] GET https://cdn.contentful.com/spaces/test1xab/content_types?limit=5 completed with status code 200 in 0.008883575006620958 seconds
D, [2018-08-06T14:21:34.687855 #11348] DEBUG -- : [httplog] GET https://cdn.contentful.com/spaces/test1xab/content_types?limit=5&skip=5 completed with status code 200 in 0.004309768002713099 seconds
D, [2018-08-06T14:21:34.706308 #11348] DEBUG -- : [httplog] GET https://cdn.contentful.com/spaces/test1xab/content_types?limit=5&skip=10 completed with status code 200 in 0.016485408996231854 seconds
D, [2018-08-06T14:21:34.711099 #11348] DEBUG -- : [httplog] GET https://cdn.contentful.com/spaces/test1xab/content_types?limit=5&skip=15 completed with status code 200 in 0.0031805979961063713 seconds
    does lazy pagination
    builds a hash of included links by ID
D, [2018-08-06T14:21:34.746170 #11348] DEBUG -- : [httplog] GET https://cdn.contentful.com/spaces/test1xab/assets?limit=5 completed with status code 200 in 0.006532204002724029 seconds
D, [2018-08-06T14:21:34.751730 #11348] DEBUG -- : [httplog] GET https://cdn.contentful.com/spaces/test1xab/assets?limit=5&skip=5 completed with status code 200 in 0.004193425003904849 seconds
    memoizes pages
    follows redirects
D, [2018-08-06T14:21:34.772747 #11348] DEBUG -- : [httplog] GET https://cdn.contentful.com/spaces/test1xab/entries?content_type=page&limit=5 completed with status code 200 in 0.006039376996341161 seconds
D, [2018-08-06T14:21:34.777706 #11348] DEBUG -- : [httplog] GET https://cdn.contentful.com/spaces/test1xab/entries?content_type=page&limit=5&skip=5 completed with status code 200 in 0.0036182339972583577 seconds
    paginates all items
D, [2018-08-06T14:21:34.784250 #11348] DEBUG -- : [httplog] GET https://cdn.contentful.com/spaces/test1xab/entries?limit=2 completed with status code 200 in 0.004676067008404061 seconds
    gets entries with query params
D, [2018-08-06T14:21:34.790065 #11348] DEBUG -- : [httplog] GET https://cdn.contentful.com/spaces/test1xab/content_types?limit=5 completed with status code 200 in 0.0033412500051781535 seconds
    does not paginate if only the first page is taken
    paginates directly when block given
  Cdn
    sync
      accepts sync token
      gets all sync items
      returns next sync token
      pages when theres a lot of items
  with environment
    get
D, [2018-08-06T14:21:34.923082 #11348] DEBUG -- : [httplog] GET https://cdn.contentful.com/spaces/test1xab/environments/specs/entries?limit=2 completed with status code 200 in 0.003700261004269123 seconds
      gets entries with query params from environment
      paginates all items

WCC::Contentful::Graphql::Builder
  from sync indexer
    resolves discriminated linked types
    resolves coordinates
    resolves linked assets
    finds types by ID
    resolves date times and json blobs
    resolves linked types
    builds a schema from loaded types
    can filter by arbitrary field
  from content type indexer
    resolves linked types
    resolves location
    finds types by ID
    resolves date times and json blobs
    builds a schema from loaded types
    resolves discriminated linked types
    resolves linked assets

WCC::Contentful::ModelMethods
  #resolve
    ignores a circular reference discovered through backlinks
    raises argument error for depth 0
    exits early if already resolved to depth
    raises on circular reference when given option circular_reference: :raise
    raises on circular reference discovered through backlinks
    instantiates a model class for an already resolved raw value
    does not resolve circular reference when given option circular_reference: :ignore
    re-resolves circular reference further down the tree
    recursively resolves links for further depth
    re-resolves to deeper depth
    resolves links for depth 1
    stops when it hits a circular reference
    keeps track of backlinks
  #resolved?
    returns true when no links in array
    raises argument error for depth 0
    calls into sub-links when depth > 1
    returns false when a single link is not resolved
    returns false when links not resolved
    returns true when all links are resolved
    returns true when broken links are nil
  #to_h
    makes a json-equivalent hash
  #to_json
    writes resolved links
    raises circular reference exception
    writes sys
    writes unresolved fields

WCC::Contentful::IndexedRepresentation
  #== works after deep dup
  deep dup duplicates all the way down to fields
  round trip deserializes from json

WCC::Contentful::SimpleClient::Management
  content_types
    uses environment
  webhook_definitions
    posts a new definition to space root
    gets webhook definitions from space root

WCC::Contentful::ModelValidators
  multiple model validations
    validation success
    validation failures
  validate_field
    should validate Boolean as bool
    should fail when expected array is not an array
    should fail when linked content types do not match regexp
    should fail when link is not of expected content type
    should fail when expected asset is not an asset
    should fail when array item is not of expected type
    should validate single link
    should validate Text as string field
    should validate links to assets
    should fail when expected link is not a link
    should validate links to content type by regexp
    should validate array of simple values
    should validate Float as float
    should error when field missing
    should error when field is not of expected type
    should validate Symbol as string field
    should validate single link with expected content type
    should validate Integer as int
    should fail when link can link to additional unspecified content types
    should validate Date as DateTime
    should validate links to one of multiple content types
  model subclasses
    can override failing base class validations
    can run even when content type singleton method is missing
    can override good base class validations
    can add extra validations that dont override base validations
    can add extra failing validations
    can add extra passing validations
    can nullify validations on parent
  when schema is from CDN not management API
    does not fail for single element link type validation because we dont have the info
    fails for mismatched array link content type because we have that info
  validate_fields
    should run multiple validations in sequence
    should error when validation fails
    overwrites earlier validations of a field
    should allow raw validation

Top 10 slowest examples (1.22 seconds, 3.4% of total time):
  WCC::Contentful.validate_models! validates successfully if all types present
    0.20771 seconds ./spec/wcc/contentful_spec.rb:417
  WCC::Contentful.init content_delivery = lazy_sync should call out to CDN for first calls only
    0.13978 seconds ./spec/wcc/contentful_spec.rb:380
  WCC::Contentful::ModelBuilder finds types by content type
    0.13329 seconds ./spec/wcc/contentful/model_builder_spec.rb:101
  WCC::Contentful.validate_models! fails validation if menus not present
    0.11307 seconds ./spec/wcc/contentful_spec.rb:433
  WCC::Contentful::ModelBuilder handles nil linked types
    0.11269 seconds ./spec/wcc/contentful/model_builder_spec.rb:276
  WCC::Contentful.init with management token should populate models via Management API cache
    0.11216 seconds ./spec/wcc/contentful_spec.rb:233
  WCC::Contentful::ModelBuilder model class registry does not use loaded class if it does not exist
    0.10472 seconds ./spec/wcc/contentful/model_builder_spec.rb:533
  WCC::Contentful.init with preview token with preview token should find draft content in Contentful if preview is set to true
    0.1043 seconds ./spec/wcc/contentful_spec.rb:105
  WCC::Contentful.init with preview token with preview token should not find draft content in Contentful if preview is set to false
    0.09857 seconds ./spec/wcc/contentful_spec.rb:83
  WCC::Contentful.init content_delivery = lazy_sync should error when trying to use preview api
    0.09733 seconds ./spec/wcc/contentful_spec.rb:359

Top 10 slowest example groups:
  Wcc::ModelGenerator
    4.23 seconds average (29.6 seconds / 7 examples) ./spec/generators/wcc/model_generator_spec.rb:10
  WCC::Contentful::ModelBuilder
    0.07439 seconds average (2.46 seconds / 33 examples) ./spec/wcc/contentful/model_builder_spec.rb:3
  WCC::Contentful
    0.0723 seconds average (1.23 seconds / 17 examples) ./spec/wcc/contentful_spec.rb:5
  WCC::Contentful::Graphql::Builder
    0.05076 seconds average (0.76134 seconds / 15 examples) ./spec/wcc/contentful/graphql/builder_spec.rb:5
  WCC::Contentful::Store::PostgresStore
    0.02301 seconds average (0.57518 seconds / 25 examples) ./spec/wcc/contentful/store/postgres_store_spec.rb:5
  WCC::Contentful::SimpleClient
    0.0153 seconds average (0.29061 seconds / 19 examples) ./spec/wcc/contentful/simple_client_spec.rb:3
  WCC::Contentful::ContentTypeIndexer
    0.01457 seconds average (0.11653 seconds / 8 examples) ./spec/wcc/contentful/content_type_indexer_spec.rb:3
  WCC::Contentful::ModelValidators
    0.01249 seconds average (0.44963 seconds / 36 examples) ./spec/wcc/contentful/model_validators_spec.rb:3
  WCC::Contentful::Store::CDNAdapter
    0.00841 seconds average (0.17651 seconds / 21 examples) ./spec/wcc/contentful/store/cdn_adapter_spec.rb:3
  WCC::Contentful::WebhookController
    0.00812 seconds average (0.06499 seconds / 8 examples) ./spec/controllers/wcc/contentful/webhook_controller_spec.rb:5

Finished in 36.01 seconds (files took 2.55 seconds to load)
283 examples, 0 failures

Randomized with seed 48117