Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename method SearchAttributeKey::forString() to ::forText() #565

Merged
merged 1 commit into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Common/SearchAttributes/SearchAttributeKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Temporal\Common\SearchAttributes\SearchAttributeKey\IntValue;
use Temporal\Common\SearchAttributes\SearchAttributeKey\KeywordListValue;
use Temporal\Common\SearchAttributes\SearchAttributeKey\KeywordValue;
use Temporal\Common\SearchAttributes\SearchAttributeKey\StringValue;
use Temporal\Common\SearchAttributes\SearchAttributeKey\TextValue;
use Temporal\Common\SearchAttributes\SearchAttributeUpdate\ValueSet;

/**
Expand Down Expand Up @@ -61,9 +61,9 @@ public static function forKeyword(string $name): KeywordValue
/**
* @param non-empty-string $name
*/
public static function forString(string $name): StringValue
public static function forText(string $name): TextValue
{
return new StringValue($name);
return new TextValue($name);
}

/**
Expand Down Expand Up @@ -92,7 +92,7 @@ public static function for(ValueType $tryFrom, string $name): self
ValueType::Int => self::forInteger($name),
ValueType::Float => self::forFloat($name),
ValueType::Keyword => self::forKeyword($name),
ValueType::String => self::forString($name),
ValueType::Text => self::forText($name),
ValueType::Datetime => self::forDatetime($name),
ValueType::KeywordList => self::forKeywordList($name),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/**
* @psalm-immutable
*/
final class StringValue extends SearchAttributeKey
final class TextValue extends SearchAttributeKey
{
public function valueSet(string|\Stringable $value): SearchAttributeUpdate
{
Expand All @@ -20,6 +20,6 @@ public function valueSet(string|\Stringable $value): SearchAttributeUpdate

public function getType(): ValueType
{
return ValueType::String;
return ValueType::Text;
}
}
2 changes: 1 addition & 1 deletion src/Common/SearchAttributes/ValueType.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ enum ValueType: string
case Int = 'int64';
case Keyword = 'keyword';
case KeywordList = 'keyword_list';
case String = 'string';
case Text = 'string';
case Datetime = 'datetime';
}
2 changes: 1 addition & 1 deletion src/Common/TypedSearchAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public function withUntypedValue(string $name, mixed $value): self
\is_float($value) => $this->withValue(SearchAttributeKey::forFloat($name), $value),
\is_array($value) => $this->withValue(SearchAttributeKey::forKeywordList($name), $value),
$value instanceof \Stringable,
\is_string($value) => $this->withValue(SearchAttributeKey::forString($name), $value),
\is_string($value) => $this->withValue(SearchAttributeKey::forText($name), $value),
$value instanceof \DateTimeInterface => $this->withValue(SearchAttributeKey::forDatetime($name), $value),
default => throw new \InvalidArgumentException('Unsupported value type.'),
};
Expand Down
2 changes: 1 addition & 1 deletion testing/src/Environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function startTemporalServer(
ValueType::Int => 'int',
ValueType::Keyword => 'keyword',
ValueType::KeywordList => 'keywordList',
ValueType::String => 'text',
ValueType::Text => 'text',
ValueType::Datetime => 'datetime',
};
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Acceptance/App/Runtime/TemporalStarter.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ public function start(): void
}

$this->environment->startTemporalServer(searchAttributes: [
'foo' => ValueType::String->value,
'foo' => ValueType::Text->value,
'bar' => ValueType::Int->value,
'testBool' => ValueType::Bool,
'testInt' => ValueType::Int,
'testFloat' => ValueType::Float,
'testString' => ValueType::String,
'testText' => ValueType::Text,
'testKeyword' => ValueType::Keyword,
'testKeywordList' => ValueType::KeywordList,
'testDatetime' => ValueType::Datetime,
Expand Down
12 changes: 6 additions & 6 deletions tests/Acceptance/Extra/Workflow/SearchAttributesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function testStartWithSearchAttributes(
'testFloat' => 1.1,
'testInt' => -2,
'testBool' => false,
'testString' => 'foo',
'testText' => 'foo',
'testKeyword' => 'bar',
'testKeywordList' => ['baz'],
'testDatetime' => new \DateTimeImmutable('2019-01-01T00:00:00Z'),
Expand All @@ -50,7 +50,7 @@ public function testStartWithSearchAttributes(
'testBool' => false,
'testInt' => -2,
'testFloat' => 1.1,
'testString' => 'foo',
'testText' => 'foo',
'testKeyword' => 'bar',
'testKeywordList' => ['baz'],
'testDatetime' => (new \DateTimeImmutable('2019-01-01T00:00:00Z'))
Expand All @@ -71,7 +71,7 @@ public function testUpsertSearchAttributes(
'testFloat' => 1.1,
'testInt' => -2,
'testBool' => false,
'testString' => 'foo',
'testText' => 'foo',
'testKeyword' => 'bar',
'testKeywordList' => ['baz'],
'testDatetime' => new \DateTimeImmutable('2019-01-01T00:00:00Z'),
Expand All @@ -82,7 +82,7 @@ public function testUpsertSearchAttributes(
'testBool' => true,
'testInt' => 42,
'testFloat' => 1.0,
'testString' => 'foo bar baz',
'testText' => 'foo bar baz',
'testKeyword' => 'foo-bar-baz',
'testKeywordList' => ['foo', 'bar', 'baz'],
'testDatetime' => '2021-01-01T00:00:00+00:00',
Expand Down Expand Up @@ -134,7 +134,7 @@ public function testUpsertSearchAttributesUnset(
'testFloat' => 1.1,
'testInt' => -2,
'testBool' => false,
'testString' => 'foo',
'testText' => 'foo',
'testKeyword' => 'bar',
'testKeywordList' => ['baz'],
'testDatetime' => new \DateTimeImmutable('2019-01-01T00:00:00Z'),
Expand All @@ -144,7 +144,7 @@ public function testUpsertSearchAttributesUnset(
$toSend = [
'testInt' => 42,
'testBool' => null,
'testString' => 'bar',
'testText' => 'bar',
'testKeyword' => null,
'testKeywordList' => ['red'],
'testDatetime' => null,
Expand Down
12 changes: 6 additions & 6 deletions tests/Acceptance/Extra/Workflow/TypedSearchAttributesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function testStartWithTypedSearchAttributes(
->withValue(SearchAttributeKey::forFloat('testFloat'), 1.1)
->withValue(SearchAttributeKey::forInteger('testInt'), -2)
->withValue(SearchAttributeKey::forBool('testBool'), false)
->withValue(SearchAttributeKey::forString('testString'), 'foo')
->withValue(SearchAttributeKey::forText('testText'), 'foo')
->withValue(SearchAttributeKey::forKeyword('testKeyword'), 'bar')
->withValue(SearchAttributeKey::forKeywordList('testKeywordList'), ['baz'])
->withValue(
Expand All @@ -56,7 +56,7 @@ public function testStartWithTypedSearchAttributes(
'testBool' => false,
'testInt' => -2,
'testFloat' => 1.1,
'testString' => 'foo',
'testText' => 'foo',
'testKeyword' => 'bar',
'testKeywordList' => ['baz'],
'testDatetime' => (new \DateTimeImmutable('2019-01-01T00:00:00Z'))
Expand All @@ -78,7 +78,7 @@ public function testUpsertTypedSearchAttributes(
->withValue(SearchAttributeKey::forFloat('testFloat'), 1.1)
->withValue(SearchAttributeKey::forInteger('testInt'), -2)
->withValue(SearchAttributeKey::forBool('testBool'), false)
->withValue(SearchAttributeKey::forString('testString'), 'foo')
->withValue(SearchAttributeKey::forText('testText'), 'foo')
->withValue(SearchAttributeKey::forKeyword('testKeyword'), 'bar')
->withValue(SearchAttributeKey::forKeywordList('testKeywordList'), ['baz'])
->withValue(
Expand All @@ -92,7 +92,7 @@ public function testUpsertTypedSearchAttributes(
'testBool' => true,
'testInt' => 42,
'testFloat' => 1.0,
'testString' => 'foo bar baz',
'testText' => 'foo bar baz',
'testKeyword' => 'foo-bar-baz',
'testKeywordList' => ['foo', 'bar', 'baz'],
'testDatetime' => '2021-01-01T00:00:00+00:00',
Expand Down Expand Up @@ -145,7 +145,7 @@ public function testUpsertTypedSearchAttributesUnset(
->withValue(SearchAttributeKey::forFloat('testFloat'), 1.1)
->withValue(SearchAttributeKey::forInteger('testInt'), -2)
->withValue(SearchAttributeKey::forBool('testBool'), false)
->withValue(SearchAttributeKey::forString('testString'), 'foo')
->withValue(SearchAttributeKey::forText('testText'), 'foo')
->withValue(SearchAttributeKey::forKeyword('testKeyword'), 'bar')
->withValue(SearchAttributeKey::forKeywordList('testKeywordList'), ['baz'])
->withValue(
Expand All @@ -158,7 +158,7 @@ public function testUpsertTypedSearchAttributesUnset(
$toSend = [
'testInt' => 42,
'testBool' => null,
'testString' => 'bar',
'testText' => 'bar',
'testKeyword' => null,
'testKeywordList' => ['red'],
'testDatetime' => null,
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/Common/TypedSearchAttributesTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public function testFromJsonArray(): void
self::assertSame(42, $collection->get(SearchAttributeKey::forInteger('name3')));
self::assertSame('bar', $collection->get(SearchAttributeKey::forKeyword('name4')));
self::assertSame(3.14, $collection->get(SearchAttributeKey::forFloat('name5')));
self::assertSame('foo', $collection->get(SearchAttributeKey::forString('name6')));
self::assertSame('foo', $collection->get(SearchAttributeKey::forText('name6')));
self::assertInstanceOf(\DateTimeImmutable::class, $collection->get(SearchAttributeKey::forDatetime('name7')));
self::assertSame(
'2021-01-01T00:00:00+00:00',
Expand All @@ -212,7 +212,7 @@ public function testFromUntypedCollection(): void
self::assertTrue($collection->get(SearchAttributeKey::forBool('name1')));
self::assertFalse($collection->get(SearchAttributeKey::forBool('name2')));
self::assertSame(42, $collection->get(SearchAttributeKey::forInteger('name3')));
self::assertSame('bar', $collection->get(SearchAttributeKey::forString('name4')));
self::assertSame('bar', $collection->get(SearchAttributeKey::forText('name4')));
self::assertSame(3.14, $collection->get(SearchAttributeKey::forFloat('name5')));
self::assertInstanceOf(\DateTimeImmutable::class, $collection->get(SearchAttributeKey::forDatetime('name7')));
self::assertSame('2021-01-01T00:00:00+00:00', $collection->get(SearchAttributeKey::forDatetime('name7'))->format(DATE_RFC3339));
Expand All @@ -225,7 +225,7 @@ public function testValues()
->withValue(SearchAttributeKey::forFloat('testFloat'), 1.1)
->withValue(SearchAttributeKey::forInteger('testInt'), -2)
->withValue(SearchAttributeKey::forBool('testBool'), false)
->withValue(SearchAttributeKey::forString('testString'), 'foo')
->withValue(SearchAttributeKey::forText('testText'), 'foo')
->withValue(SearchAttributeKey::forKeyword('testKeyword'), 'bar')
->withValue(SearchAttributeKey::forKeywordList('testKeywordList'), ['baz'])
->withValue(
Expand Down
Loading